How to connect to a Web API?

,

TLDR: Please explain to me like I’m a child how Web API’s work.

I use project management software called ClickUp that says you can push and pull data to it through its web API. From its documentation, if you click on Lists on the left side, then Get List in the middle, there are dropdown menus that show examples of how to fetch a list in many languages (except Julia). There is also a raw example (whatever that means), so I assume it is possible to use Julia also. I would like to read a List from ClickUp into a Julia DataFrame, manipulate, then push back. Authentication is another hurdle I will have to handle somehow. Can someone outline the general steps I need to take with Julia to interact with a web app like ClickUp?

1 Like

Using the HTTP.jl library you can make equivalent calls to the curl examples. Some knowledge of general HTTP verbs / requests / responses / etc would be helpful to translate.

But just as an (untested) example to get you started

# curl --include \
#     --header "Authorization: "access_token"" \
#  'https://api.clickup.com/api/v2/list/{list_id}'

using HTTP
using JSON3

access_token = "...."  # your api key
list_id = 1

resp = HTTP.get(
      "https://api.clickup.com/api/v2/list/$(list_id)",  # url
      [
          "Authorization" => access_token  # headers by pairs
      ]
)

data = JSON3.read(resp.body)  # json data as a dict-like structure

4 Likes