Skip to content

OData

Read OData v2/v4 REST services from SQL, with $filter pushdown, automatic paging and metadata discovery

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/odata/index.md to help me query OData with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Read the first 5 People entities and pull a field out of the raw JSON.

Example output Β· captured
Connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT seq, json_extract_string(entity, '$.FirstName') AS first_name
FROM odata.main.odata_query('https://services.odata.org/V4/TripPinService', 'People', top := '5')
ORDER BY seq;
Result
seq first_name
0 Russell
1 Scott
2 Ronald
3 Javier
4 Willie

Quick start

Choose where to run OData, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'odata' AS odata (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-odata'
);

3. Run a query

query.sql
SELECT seq, json_extract_string(entity, '$.FirstName') AS first_name
FROM odata.main.odata_query('https://services.odata.org/V4/TripPinService', 'People', top := '5')
ORDER BY seq;
More example queries β†’
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'odata' AS odata (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Query OData v2/v4 services and return their entities as rows

Catalog

Everything odata exposes once attached β€” read straight from the worker's released build.

odata 1 schema
main 1 view Β· 3 functions

OData read functions: entity-set discovery, entity reads, and $metadata parsing.

Schema examples (6)
Examples (6)

Discover every entity set the TripPin OData service exposes.

SELECT name
FROM odata.main.odata_entity_sets('https://services.odata.org/V4/TripPinService')
ORDER BY name;

Read the first 5 People entities and project a field out of the raw JSON.

SELECT seq, json_extract_string(entity, '$.FirstName') AS first_name
FROM odata.main.odata_query('https://services.odata.org/V4/TripPinService', 'People', top := '5');

Inspect the Person entity type's properties and EDM types from $metadata.

SELECT property, type
FROM odata.main.odata_metadata('https://services.odata.org/V4/TripPinService')
WHERE entity_type = 'Person';

Profile data completeness: for every property the Person entity type declares in $metadata, count how many TripPin People entities carry a non-empty value (not null, an empty string, or an empty collection), least-populated first.

SELECT m.property, m.type,
  count(*) FILTER (WHERE coalesce(json_extract(p.entity, '$.' || m.property)::VARCHAR, 'null') NOT IN ('null', '""', '[]')) AS populated,
  count(*) AS people
FROM odata.main.odata_metadata('https://services.odata.org/V4/TripPinService') AS m
CROSS JOIN odata.main.odata_query('https://services.odata.org/V4/TripPinService', 'People') AS p
WHERE m.entity_type = 'Person'
GROUP BY m.property, m.type
ORDER BY populated, m.property;
2 more examples

Summarise every numeric column of the Northwind Products entity set: take the Product properties $metadata declares as Edm.Int16/Int32/Decimal/Double and compute each one's min, max and average across all products.

WITH product_values AS (SELECT m.property, m.type, TRY_CAST(json_extract_string(p.entity, '$.' || m.property) AS DOUBLE) AS amount FROM odata.main.odata_metadata('https://services.odata.org/V4/Northwind/Northwind.svc') AS m CROSS JOIN odata.main.odata_query('https://services.odata.org/V4/Northwind/Northwind.svc', 'Products') AS p WHERE m.entity_type = 'Product' AND m.type IN ('Edm.Int16', 'Edm.Int32', 'Edm.Decimal', 'Edm.Double')) SELECT property, type, min(amount) AS min_value, max(amount) AS max_value, round(avg(amount), 2) AS avg_value
FROM product_values
GROUP BY property, type
ORDER BY property;

Join two entity sets client-side: the five Northwind customers with the most orders, matching Orders to Customers on CustomerID and pushing $select down so only the needed fields are fetched.

SELECT json_extract_string(c.entity, '$.CompanyName') AS company,
  json_extract_string(c.entity, '$.Country') AS country, count(*) AS orders
FROM odata.main.odata_query('https://services.odata.org/V4/Northwind/Northwind.svc', 'Customers', "select" := 'CustomerID,CompanyName,Country') AS c
JOIN odata.main.odata_query('https://services.odata.org/V4/Northwind/Northwind.svc', 'Orders', "select" := 'OrderID,CustomerID') AS o ON json_extract_string(o.entity, '$.CustomerID') = json_extract_string(c.entity, '$.CustomerID')
GROUP BY company, country
ORDER BY orders DESC, company
LIMIT 5;
Views
odata_public_services 2 examples4 cols

Curated registry of well-known public, auth-free OData services to try with the OData functions

Columns
name VARCHAR
Short human-friendly name of the public OData service.
service_url VARCHAR
Service root URL; pass it to odata_entity_sets, odata_metadata, or odata_query.
odata_version VARCHAR
OData protocol version: 'v2', 'v3', or 'v4' (use version := 'v2' on odata_query for v2).
description VARCHAR
What the service contains.
Examples (2)

List the auth-free public OData v4 services this worker ships, newest-style first.

SELECT name, service_url
FROM odata.main.odata_public_services
WHERE odata_version = 'v4'
ORDER BY name;

Count the registered public services grouped by OData protocol version.

SELECT odata_version, count(*) AS services
FROM odata.main.odata_public_services
GROUP BY odata_version
ORDER BY odata_version;
Link
Table functions
odata_entity_sets (service_url VARCHAR, token := VARCHAR) 1 example

List the entity sets exposed by an OData service (from its service document)

Positional arguments
service_url VARCHAR
OData service root URL
Named arguments
token := VARCHAR
Bearer token (Authorization: Bearer <token>) Β· default ""
Returns columns
name VARCHAR
Name of an entity set advertised in the service document; pass it as the entity_set argument to odata_query.
Example

Discover every entity set the TripPin OData service exposes (People, Airlines, Airports, ...).

SELECT name
FROM odata.main.odata_entity_sets('https://services.odata.org/V4/TripPinService')
ORDER BY name;
Link
odata_metadata (service_url VARCHAR, token := VARCHAR) 2 examples

Parse an OData service's $metadata (EDMX XML); one row per entity-type property

Positional arguments
service_url VARCHAR
OData service root URL
Named arguments
token := VARCHAR
Bearer token (Authorization: Bearer <token>) Β· default ""
Returns columns
entity_type VARCHAR
Name of the EDM entity type the property belongs to.
property VARCHAR
Name of a property declared on that entity type.
type VARCHAR
The property's EDM type, e.g. Edm.String, Edm.Int32, Edm.DateTimeOffset.
Examples (2)

Inspect the properties and EDM types of the Person entity type from the service's $metadata (EDMX) document.

SELECT property, type
FROM odata.main.odata_metadata('https://services.odata.org/V4/TripPinService')
WHERE entity_type = 'Person';

Profile data completeness: for every property the Person entity type declares in $metadata, count how many TripPin People entities carry a non-empty value (not null, an empty string, or an empty collection), least-populated first.

SELECT m.property, m.type,
  count(*) FILTER (WHERE coalesce(json_extract(p.entity, '$.' || m.property)::VARCHAR, 'null') NOT IN ('null', '""', '[]')) AS populated,
  count(*) AS people
FROM odata.main.odata_metadata('https://services.odata.org/V4/TripPinService') AS m
CROSS JOIN odata.main.odata_query('https://services.odata.org/V4/TripPinService', 'People') AS p
WHERE m.entity_type = 'Person'
GROUP BY m.property, m.type
ORDER BY populated, m.property;
Link
odata_query (service_url VARCHAR, entity_set VARCHAR, filter := VARCHAR, select := VARCHAR, orderby := VARCHAR, top := VARCHAR, max_rows := BIGINT, token := VARCHAR, version := VARCHAR) 4 examples

Read an OData entity set; one row per entity (raw JSON), following nextLink paging

Positional arguments
service_url VARCHAR
OData service root URL
entity_set VARCHAR
Entity set name (path segment under the service root)
Named arguments
filter := VARCHAR
$filter system query option Β· default ""
select := VARCHAR
$select system query option Β· default ""
orderby := VARCHAR
$orderby system query option Β· default ""
top := VARCHAR
$top system query option Β· default ""
max_rows := BIGINT
Maximum entities to collect across pages Β· default 10000
token := VARCHAR
Bearer token (Authorization: Bearer <token>) Β· default ""
version := VARCHAR
OData response shape: 'v4' (value/@odata.nextLink) or 'v2' (d.results/d.__next) Β· default "v4"
Returns columns
seq BIGINT
0-based position of the entity across all fetched pages.
entity VARCHAR
The entity as its raw JSON object text; project fields with json_extract / json_extract_string.
Examples (4)

Read the first 5 People entities from the public TripPin OData v4 service and pull a field out of the raw JSON.

SELECT seq, json_extract_string(entity, '$.FirstName') AS first_name
FROM odata.main.odata_query('https://services.odata.org/V4/TripPinService', 'People', top := '5');

Join two entity sets client-side: the five Northwind customers with the most orders, matching Orders to Customers on CustomerID and pushing $select down so only the needed fields are fetched.

SELECT json_extract_string(c.entity, '$.CompanyName') AS company,
  json_extract_string(c.entity, '$.Country') AS country, count(*) AS orders
FROM odata.main.odata_query('https://services.odata.org/V4/Northwind/Northwind.svc', 'Customers', "select" := 'CustomerID,CompanyName,Country') AS c
JOIN odata.main.odata_query('https://services.odata.org/V4/Northwind/Northwind.svc', 'Orders', "select" := 'OrderID,CustomerID') AS o ON json_extract_string(o.entity, '$.CustomerID') = json_extract_string(c.entity, '$.CustomerID')
GROUP BY company, country
ORDER BY orders DESC, company
LIMIT 5;

Summarise every numeric column of the Northwind Products entity set: take the Product properties $metadata declares as Edm.Int16/Int32/Decimal/Double and compute each one's min, max and average across all products.

WITH product_values AS (SELECT m.property, m.type, TRY_CAST(json_extract_string(p.entity, '$.' || m.property) AS DOUBLE) AS amount FROM odata.main.odata_metadata('https://services.odata.org/V4/Northwind/Northwind.svc') AS m CROSS JOIN odata.main.odata_query('https://services.odata.org/V4/Northwind/Northwind.svc', 'Products') AS p WHERE m.entity_type = 'Product' AND m.type IN ('Edm.Int16', 'Edm.Int32', 'Edm.Decimal', 'Edm.Double')) SELECT property, type, min(amount) AS min_value, max(amount) AS max_value, round(avg(amount), 2) AS avg_value
FROM product_values
GROUP BY property, type
ORDER BY property;
1 more example

Count the German customers in the public Northwind OData v4 sample, pushing the predicate down to the service via the OData $filter option.

SELECT count(*)
FROM odata.main.odata_query('https://services.odata.org/V4/Northwind/Northwind.svc', 'Customers', "filter" := 'Country eq ''Germany''', max_rows := 1000);
Link

Try these queries

Discover the entity sets the TripPin OData service exposes.

SELECT name
FROM odata.main.odata_entity_sets('https://services.odata.org/V4/TripPinService')
ORDER BY name;

Uses odata_entity_sets

Inspect the properties and EDM types of the Person entity type from $metadata.

SELECT property, type
FROM odata.main.odata_metadata('https://services.odata.org/V4/TripPinService')
WHERE entity_type = 'Person'
ORDER BY property;

Uses odata_metadata

Read the first 5 People entities and project a field out of the raw JSON.

SELECT seq, json_extract_string(entity, '$.FirstName') AS first_name
FROM odata.main.odata_query('https://services.odata.org/V4/TripPinService', 'People', top := '5')

Uses odata_query

Inspect the Person entity type's properties and EDM types from $metadata.

SELECT property, type
FROM odata.main.odata_metadata('https://services.odata.org/V4/TripPinService')
WHERE entity_type = 'Person'

Uses odata_metadata

Profile data completeness: for every property the Person entity type declares in $metadata, count how many TripPin People entities carry a non-empty value (not null, an empty string, or an empty collection), least-populated first.

SELECT m.property, m.type,
  count(*) FILTER (WHERE coalesce(json_extract(p.entity, '$.' || m.property)::VARCHAR, 'null') NOT IN ('null', '""', '[]')) AS populated,
  count(*) AS people
FROM odata.main.odata_metadata('https://services.odata.org/V4/TripPinService') AS m
CROSS JOIN odata.main.odata_query('https://services.odata.org/V4/TripPinService', 'People') AS p
WHERE m.entity_type = 'Person'
GROUP BY m.property, m.type
ORDER BY populated, m.property

Uses odata_metadataodata_query

List the auth-free public OData v4 services this worker ships, newest-style first.

SELECT name, service_url
FROM odata.main.odata_public_services
WHERE odata_version = 'v4'
ORDER BY name

Uses odata_public_services

4 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Using the OData service at https://services.odata.org/V4/TripPinService, list the names of every entity set it exposes.
  • How many People entities does the TripPin OData service at https://services.odata.org/V4/TripPinService contain in total (across all pages)?
  • This OData extension ships a built-in registry of well-known public OData services. List the name and service_url of every OData v4 service in that registry.

OData is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.