Skip to main content

API for CSV converted by udata-hydra

Project description

udata-hydra-csvapi

This connects to udata-hydra and serves the converted CSVs as an API.

Run locally

Start udata-hydra via docker compose.

Launch this project:

docker compose up

You can now access the raw postgrest API on http://localhost:8080.

Now you can launch the proxy (ie the app):

poetry install
poetry run adev runserver -p8005 udata_hydra_csvapi/app.py

And query postgrest via the proxy using a resource_id, cf below. Test resource_id is 27d469ff-9908-4b7e-a2e0-9439bb38a395

API

Meta informations on resource

curl http://localhost:8005/api/resources/27d469ff-9908-4b7e-a2e0-9439bb38a395/
{
  "created_at": "2023-02-11T11:44:03.875615+00:00",
  "url": "https://data.toulouse-metropole.fr//explore/dataset/boulodromes/download?format=csv&timezone=Europe/Berlin&use_labels_for_header=false",
  "links": [
    {
      "href": "/api/resources/27d469ff-9908-4b7e-a2e0-9439bb38a395/profile/",
      "type": "GET",
      "rel": "profile"
    },
    {
      "href": "/api/resources/27d469ff-9908-4b7e-a2e0-9439bb38a395/data/",
      "type": "GET",
      "rel": "data"
    }
  ]
}

Profile (csv-detective output) for a resource

curl http://localhost:8005/api/resources/27d469ff-9908-4b7e-a2e0-9439bb38a395/profile/
{
  "profile": {
    "header": [
        "geo_point_2d",
        "geo_shape",
        "ins_nom",
        "ins_complexe_nom_cplmt",
        "ins_codepostal",
        "secteur",
        "..."
    ]
  },
  "...": "..."
}

Data for a resource (ie resource API)

curl http://localhost:8005/api/resources/27d469ff-9908-4b7e-a2e0-9439bb38a395/data/
{
  "data": [
    {
      "__id": 1,
      "geo_point_2d": "43.58061543292057,1.401751073689455",
      "geo_shape": {
        "coordinates": [
          [
              1.401751073689455,
              43.58061543292057
            ]
          ],
          "type": "MultiPoint"
        },
      "ins_nom": "BOULODROME LOU BOSC",
      "ins_complexe_nom_cplmt": "COMPLEXE SPORTIF DU MIRAIL",
      "ins_codepostal": 31100,
      "secteur": "Toulouse Ouest",
      "quartier": 6.3,
      "acces_libre": null,
      "ins_nb_equ": 1,
      "ins_detail_equ": "",
      "ins_complexe_nom": "",
      "ins_adresse": "",
      "ins_commune": "",
      "acces_public_horaires": null,
      "acces_club_scol": null,
      "ins_nom_cplmt": "",
      "ins_id_install": ""
    }
  ],
  "links": {
    "next": "/api/resources/60963939-6ada-46bc-9a29-b288b16d969b/data/?page=2&page_size=1",
    "prev": null,
    "profile": "/api/resources/60963939-6ada-46bc-9a29-b288b16d969b/profile/"
  },
  "meta": {"page": 1, "page_size": 1, "total": 2}
}

This endpoint can be queried with the following operators as query string:

# sort by column
column_name__sort=asc
column_name__sort=desc

# contains
column_name__contains=word

# exacts
column_name__exact=word

# less
column_name__less=12

# greater
column_name__greater=12

Pagination is made throught queries with page and page_size:

curl http://localhost:8005/api/resources/27d469ff-9908-4b7e-a2e0-9439bb38a395/data/?page=2&page_size=30

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

udata_hydra_csvapi-0.1.0.dev177.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

udata_hydra_csvapi-0.1.0.dev177-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file udata_hydra_csvapi-0.1.0.dev177.tar.gz.

File metadata

  • Download URL: udata_hydra_csvapi-0.1.0.dev177.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.15 Linux/5.15.0-1039-aws

File hashes

Hashes for udata_hydra_csvapi-0.1.0.dev177.tar.gz
Algorithm Hash digest
SHA256 285478b96016f3c7ff5c21f9a3a5dfddfedeb73ea500b31063a915260ed4ae4f
MD5 7f977d2999b8acbc006762fa0ea9a35c
BLAKE2b-256 1ac8368265d730bfd6bf7e0534f81a4995ec9eef953c6584032f9f37b81bb426

See more details on using hashes here.

File details

Details for the file udata_hydra_csvapi-0.1.0.dev177-py3-none-any.whl.

File metadata

File hashes

Hashes for udata_hydra_csvapi-0.1.0.dev177-py3-none-any.whl
Algorithm Hash digest
SHA256 245365db2784a289aa8526a32b4b99a9114aa76a565c6747eb91f963534d2c7d
MD5 db309b936421b9a62106aa78fde20058
BLAKE2b-256 149d071e01282749a7405f68803834f743902dd5c2e4f80413d03dd71bb4fa51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page