sfu-db / APIConnectors

A curated list of example code to collect data from Web APIs using DataPrep.Connector.
https://github.com/sfu-db/dataprep#connector
34 stars 25 forks source link

How could I add an API via the generator? #150

Open Hakureiremu opened 3 months ago

Hakureiremu commented 3 months ago

I hope to add some new APIs for this project but faced some problems during using the generator part. I have studied the guidance of adding APIs via making API describing configuration, while I'm more interested in the generator function mentioned in the paper. I use the harvardartmuseum(HVM) API as a test for the generator. As described in its API's documentation, the apikey is filled in Query Params. I successfully constructed my request and got correct response using Postman, while problems arose when I used the generator to send a sample request. Initially, in the 3rd box(Authorization), I selected QueryParam as authentication option, and filled the key-value pair with apikey:content of my apikey. However, error message noted me that there is a KeyError in ui.py as the figure below. image I thought client_id and client_secret are not required for accessing HVM API, and this error seemed like a delete of an empty key in a dictionary, so I tried two methods to bypass this error. First I tried to comment that part of the code locally, but the error still exists.
image Second I tried to give these 3 keys a default value, but it arose more errors in pydantic package. I think these fields might be compulsory for this framework.
Moreover, if I tried to choose "No Authorization" option and write the query pair apikey:content of my apikey into the 2nd box. The generator normally return Unauthorized as I think.
image So I want to ask how to fill the 3 fields in Authorization box: client_id, client_secret and access_token if I want to use generator to send sample requests to generate api configuration.