This is a new service – your feedback will help us to improve it.

API

You can use the Data Marketplace API to:

  • submit and update your data in the Data Marketplace catalogue
  • search for your data in the Data Marketplace catalogue using keywords and other search terms

API credentials

You can create credentials for 2 environments:

Sandbox
https://api.sandbox.datamarketplace.gov.uk/v1
Production
https://api.datamarketplace.gov.uk/v1

Security scopes

Each API endpoint requires one of the following security scopes:

  • discover – to search and retrieve your data
  • publish – to publish or update your data
  • delete – to delete your data

When you create your credentials, they'll have all 3 scopes by default. You can change this if required.

Authentication using tokens

You need to pass your credentials to the token endpoint to generate an access token.

To call the token endpoint, construct a request with the following information (replacing the URL, client secret and client id):

    POST {API URL}/ClientAuth/get-token HTTP/1.1
    Content-Type: application/x-www-form-urlencoded

    grant_type=client_credentials&scope=discover%2Cpublish&client_id={your-client-ID}&client_secret={your-client-secret}
    

This request will return an access token like the one below:

    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
    

You need to present the access token when you call API endpoints.

To do this, construct a request like the one below. It needs a header called ‘Authorization’ with a value set to ‘Bearer {access token}’ with every call made to the API:

    GET {API URL}/catalogued-resources HTTP/1.1
    Authorization: Bearer {access token}
    

Endpoints