Skip to main content

Publish an OData API

API Studio

An OData API is an API Studio collection of type OData. It serves OData V4: a service document, $metadata, and entity sets that Excel, Power BI and other OData clients read directly.

Create the API​

  1. Open API Studio and select New API.
  2. Set Type to OData.
  3. Under Start from, choose OData service, or From a connection to start from a table.
  4. Select Create API.

Design the model​

The Visual view of API Studio > Design > Designer shows the OData designer.

  • Namespace names the schema in $metadata.
  • Entity types hold properties, each with a name, an Edm type and Nullable.
  • Key marks the key properties. A key property is never nullable.
  • Searchable marks the text properties that $search reads.
  • Navigation properties point to another entity type, as one item or a collection. Entity set names the set the related rows come from, and Joins on pairs a property of this type with a property of the related type.
  • Entity sets publish an entity type under a name in the URL.

Fix before publishing lists what must change before the API can be served.

Choose where rows come from​

Each entity set has a Rows come from setting.

SettingRows
Sample rowsThe sample rows saved with the API.
FlowA flow you name by Project ID and Workflow ID. The flow receives the parsed query options in request.odata and returns the rows.
Connection objectA table on a database connection, chosen by Connection, with Database, Schema and Table.

For a connection object, $filter, $select, $orderby, $top, $skip, $search and $expand run in the database. Every value is sent as a query parameter. The query is read only. An expanded set must be a table on the same connection.

What a deployed OData API answers​

The service root is the API's address:

/t/<account>/<environment>/<api>/<version>/
RequestAnswer
GET /The service document, listing the entity sets.
GET /$metadataCSDL XML. Add $format=json or Accept: application/json for CSDL JSON.
GET /<Set>The rows, with @odata.context.
GET /<Set>(<key>)One entity by key. A composite key is written A=1,B='x'.
GET /<Set>/$countThe row count as plain text.

Entity set queries accept $filter, $select, $orderby, $top, $skip, $count, $search and $expand.

  • $filter supports eq, ne, gt, ge, lt, le, and, or, not, parentheses, contains, startswith, endswith and null.
  • $search matches words and "quoted phrases" in the searchable properties, ignoring case. It supports AND, OR, NOT and parentheses. Words next to each other mean AND.
  • $expand adds related rows through a navigation property, as in $expand=Orders($select=Id,Total;$filter=Total gt 100;$orderby=Total desc;$top=5). Inside the parentheses it accepts $select, $filter, $orderby, $top and a nested $expand.
  • A collection navigation answers an array. A single navigation answers an object, or null.
  • $expand has a depth limit and a limit on navigation properties per level. $search has a length limit and a term limit. A query past a limit answers 400.
  • Large results are paged. Each page carries @odata.nextLink until the last one.
  • Prefer: odata.maxpagesize=<n> sets a smaller page size.
  • Every answer carries OData-Version: 4.0.
  • A query that cannot be read answers 400 in the OData error format.
  • $search on a type with no searchable property answers 400.
  • $expand=*, a navigation with no entity set or join, and an expand that cannot run where the rows are kept answer 501.
  • $batch, delta links and $apply are not supported.

Keys, policies, limits and analytics work as on every deployed API. See Calling a deployed API.

Download the documents​

API Studio > Design > Docs on an OData API has an OData documents card.

  • $metadata (CSDL) downloads as XML or JSON.
  • Generated OpenAPI 3.1 downloads as JSON or YAML.

Read it from Excel​

  1. Deploy the API and create an API key. See Clients and keys.
  2. In Excel, open Data > Get Data > From Other Sources > From OData Feed.
  3. Select Advanced and enter the service root URL.
  4. Add the header X-API-Key with your key.
  5. Pick an entity set and select Load.

Read it from Power BI​

  1. In Power BI Desktop, open Get Data > OData feed.
  2. Select Advanced and enter the service root URL.
  3. Add the header X-API-Key with your key.
  4. Pick an entity set and select Load.
  5. Select Refresh to read the rows again.