Getting started overview

To begin working with the City, Nantes Open Data portal, developers must first register for an account, which grants access to the platform's features and API key management. The primary method for data interaction is through the Opendatasoft platform's API, which provides access to datasets in various formats, including JSON and CSV. This guide details the steps from account creation to executing a basic query, enabling users to retrieve information such as public transport schedules, urban planning documents, and environmental data for the Nantes Métropole region.

The entire process involves three primary stages: establishing an account, generating an API key (referred to as an 'App Token' by Opendatasoft), and then constructing and executing your first API request using this token. Familiarity with RESTful API concepts and JSON data structures is beneficial for working with these datasets efficiently. The Opendatasoft platform, which powers the Nantes Métropole Open Data portal, provides extensive documentation for its general API functionalities, complementing the specific datasets offered by Nantes.

Step What to do Where
1. Account Creation Register for a user account on the Nantes Métropole Open Data portal. Nantes Métropole API Quick Start
2. Generate API Key Create an 'App Token' from your account dashboard to authenticate API requests. User Dashboard > API Keys (Nantes Métropole API documentation)
3. First Request Construct and execute an API call using your generated App Token. Any HTTP client (e.g., cURL, Postman, browser)

Create an account and get keys

Access to the City, Nantes Open Data API requires an account and an associated API key, or 'App Token'. This token authenticates your requests and helps the platform manage API usage. Follow these steps to set up your access:

  1. Navigate to the Portal: Go to the official Nantes Métropole Open Data portal homepage.
  2. Initiate Registration: Look for a 'Sign up' or 'Register' link, typically found in the top right corner of the page. This will direct you to an account creation form.
  3. Complete Registration: Provide the required information, which usually includes an email address, desired username, and a secure password. Agree to any terms of service or privacy policies. Verify your email address if prompted, as this is a common step for account activation on open data platforms.
  4. Log In: Once your account is active, log in to the portal using your new credentials.
  5. Access API Keys Section: After logging in, locate your user dashboard or profile settings. There should be a specific section dedicated to 'API Keys' or 'App Tokens'. The precise navigation can vary, but it is often under 'My Account' or 'Developers' settings within the portal. The Nantes Métropole API quick start guide provides details on locating this section.
  6. Generate New App Token: Within the API keys section, you will find an option to generate a new API key. Click this button. The platform will typically generate a unique alphanumeric string. Copy this string immediately and store it securely. This App Token is your credential for making authenticated API calls.

It is critical to treat your App Token as sensitive information. Do not embed it directly into client-side code that could be publicly accessible. For server-side applications, use environment variables or a secure configuration management system to store and retrieve your token. This practice aligns with general security recommendations for API key management, as detailed in resources like the Google Maps Platform API security best practices, which emphasizes protecting credentials.

Your first request

With your App Token secured, you can now make your first request to the City, Nantes Open Data API. We'll use a simple query to retrieve data from a commonly available dataset. For this example, we will query a dataset named stationnement-en-ouvrage-real-time-disponibilites-nantes, which provides real-time parking availability in Nantes car parks. This dataset is openly accessible and does not require advanced filtering for an initial test.

The base URL for the Opendatasoft API used by Nantes Métropole is https://data.nantesmetropole.fr/api/explore/v2.1/catalog/datasets/. To this, you append the dataset identifier and any query parameters.

Example using cURL

cURL is a command-line tool and library for transferring data with URLs, widely used for testing APIs. Replace YOUR_APP_TOKEN with the actual App Token you generated.

curl -X GET \
  "https://data.nantesmetropole.fr/api/explore/v2.1/catalog/datasets/stationnement-en-ouvrage-real-time-disponibilites-nantes/records?limit=10&apikey=YOUR_APP_TOKEN" \
  -H "Accept: application/json"

This command requests the first 10 records from the real-time parking availability dataset. The limit=10 parameter restricts the number of results, and apikey=YOUR_APP_TOKEN authenticates your request. The -H "Accept: application/json" header specifies that you prefer a JSON response.

Example using Python

For programmatic access, Python with the requests library is a common choice.

import requests
import json

APP_TOKEN = "YOUR_APP_TOKEN" # Replace with your actual App Token
DATASET_ID = "stationnement-en-ouvrage-real-time-disponibilites-nantes"
BASE_URL = "https://data.nantesmetropole.fr/api/explore/v2.1/catalog/datasets/"

url = f"{BASE_URL}{DATASET_ID}/records"

params = {
    "limit": 5,
    "apikey": APP_TOKEN
}

headers = {
    "Accept": "application/json"
}

try:
    response = requests.get(url, params=params, headers=headers)
    response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
    data = response.json()
    print(json.dumps(data, indent=2))
except requests.exceptions.HTTPError as http_err:
    print(f"HTTP error occurred: {http_err}")
except Exception as err:
    print(f"An error occurred: {err}")

This Python script constructs the URL and parameters, then sends a GET request. It prints the first 5 records in a human-readable JSON format. The response.raise_for_status() call is crucial for catching HTTP errors, providing immediate feedback if the request fails due to authentication issues or incorrect parameters.

Expected Output

A successful response will return a JSON object containing a results array, where each element represents a record from the dataset. The structure of each record varies by dataset but will typically include fields like id_ouvrage, nom_ouvrage, nb_places_disponibles (number of available spaces), and etat (status) for the parking dataset.

{
  "total_count": 123, // Example total count
  "results": [
    {
      "id_ouvrage": "N_PAR_Baco",
      "nom_ouvrage": "Parking Baco",
      "nb_places_disponibles": 75,
      "etat": "Ouvert",
      "geo_point_2d": {
        "lon": -1.554,
        "lat": 47.214
      },
      "last_update": "2026-05-29T10:30:00+00:00"
    },
    {
      "id_ouvrage": "N_PAR_Bouffay",
      "nom_ouvrage": "Parking Bouffay",
      "nb_places_disponibles": 120,
      "etat": "Ouvert",
      "geo_point_2d": {
        "lon": -1.556,
        "lat": 47.216
      },
      "last_update": "2026-05-29T10:30:00+00:00"
    }
  ] 
}

The exact content of the results array will depend on the current state of the parking facilities and the specific dataset schema. Inspecting the JSON output confirms successful communication with the API and proper authentication.

Common next steps

After successfully retrieving data with your first API call, consider these common next steps to expand your interaction with the City, Nantes Open Data portal:

  • Explore More Datasets: The portal hosts a wide array of datasets beyond parking availability. Browse the full catalog of Nantes Métropole datasets to discover data on transport, environment, finance, culture, and more. Each dataset has its own specific API endpoint and schema.
  • Understand Query Parameters: The Opendatasoft API supports various query parameters for filtering, sorting, and aggregating data. Parameters like q for full-text search, refine for faceted filtering, and sort for ordering results are powerful tools. Consult the Opendatasoft API documentation for detailed parameter usage. For instance, to filter the parking dataset by a specific car park name, you might use &q=Baco.
  • Implement Advanced Filtering: Learn to construct more complex queries using the filtering capabilities. This might involve spatial queries to retrieve data within a specific geographical area, or time-based filters to get data from a particular period. The Opendatasoft platform leverages standard query language features for this, allowing granular control over the data returned.
  • Pagination: For datasets with many records, implement pagination using the limit and offset parameters to retrieve data in manageable chunks. The default limit is often 10 or 20 records, and requesting data in pages is essential for large-scale data retrieval.
  • Error Handling: Implement robust error handling in your applications. The API will return specific HTTP status codes (e.g., 400 for bad request, 401 for unauthorized, 403 for forbidden, 404 for not found, 500 for internal server error) along with a JSON body explaining the error. Properly handling these responses ensures your application remains stable and provides useful feedback to users.
  • Data Visualization and Integration: Once you can reliably retrieve data, consider how to visualize it or integrate it into other applications. Tools like Tableau, Power BI, or even custom web mapping applications using libraries like Leaflet.js or OpenLayers can consume GeoJSON data directly from the API.
  • Monitor API Usage: Keep an eye on your API key usage, if available, in your account dashboard. While the Nantes Open Data portal is free, monitoring usage ensures you stay within any implicit rate limits and helps diagnose unexpected behavior.

Troubleshooting the first call

If your initial API call does not return the expected data, consider these common troubleshooting steps:

  • Check your App Token: Ensure your apikey parameter contains the correct and complete App Token. Any typos or missing characters will result in an authentication failure, typically a 401 Unauthorized or 403 Forbidden HTTP status code. Regenerate the token if you suspect it's corrupted or lost.
  • Verify the Dataset ID: Double-check that the dataset identifier in your URL (e.g., stationnement-en-ouvrage-real-time-disponibilites-nantes) exactly matches one from the Nantes Métropole dataset catalog. A misspelled ID will lead to a 404 Not Found error.
  • Review URL Structure: Ensure all slashes, parameters, and question marks are correctly placed in the URL. A common mistake is an incorrect base URL or improperly formatted query parameters. The Opendatasoft API expects parameters after a ? and separated by &.
  • HTTP Method: Confirm that you are using the correct HTTP method, which is typically GET for retrieving data from this read-only API.
  • Check Network Connectivity: Ensure your machine has an active internet connection and no firewall rules are blocking outgoing requests to data.nantesmetropole.fr.
  • Inspect Error Messages: The API usually returns informative JSON error messages when a request fails. Parse these messages carefully. For example, a "message": "Invalid parameter value for 'limit'" indicates an issue with your limit parameter.
  • Consult Official Documentation: Refer to the Nantes Métropole API quick start guide and the broader Opendatasoft API documentation for specific endpoint details and error codes. The documentation provides examples and explanations for common issues.
  • Try a Different Dataset: If one dataset is problematic, try making a simple request to another known-good dataset (e.g., a small static dataset) to rule out issues specific to the chosen dataset or your general API access.
  • Use a Browser: For simple GET requests, try pasting the API URL (including parameters and App Token) directly into your web browser's address bar. This can sometimes provide clearer error messages or confirm if the URL itself is the problem, as browsers typically handle JSON responses gracefully.