跳转到主要内容

由udata-hydra转换的CSV的API

项目描述

Api-tabular

此连接到udata-hydra,并作为API提供转换后的CSV。

本地运行

通过docker compose启动udata-hydra

启动此项目

docker compose up

现在您可以通过http://localhost:8080访问原始postgrest API。

现在可以启动代理(即应用程序)

poetry install
poetry run adev runserver -p8005 api_tabular/app.py        # Api related to apified CSV files by udata-hydra
poetry run adev runserver -p8005 api_tabular/metrics.py    # Api related to udata's metrics

并通过使用resource_id通过代理查询postgrest,如以下所示。测试resource_id为27d469ff-9908-4b7e-a2e0-9439bb38a395

API

资源元信息

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"
    }
  ]
}

资源的配置文件(csv-detective输出)

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",
        "..."
    ]
  },
  "...": "..."
}

资源的数据(即资源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}
}

此端点可以通过以下操作符作为查询字符串进行查询

# 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

分页通过带有pagepage_size的查询来实现

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

项目详情


下载文件

下载适用于您平台的文件。如果您不确定该选择哪个,请了解更多关于安装包的信息。

源代码分发

udata_hydra_csvapi-0.1.0.dev222.tar.gz (7.3 kB 查看哈希值)

上传时间 源代码

构建分发

udata_hydra_csvapi-0.1.0.dev222-py3-none-any.whl (8.3 kB 查看哈希值)

上传时间 Python 3

由支持