From 708ba2411292707ffbbfd1acc0d88491afe08ead Mon Sep 17 00:00:00 2001 From: mcarans Date: Tue, 17 Nov 2026 16:56:48 +1300 Subject: [PATCH] Link to HDX core concepts in docs and rename API key page to API token Replace the stale website steps in the API key how-to with a link to HDX core concepts, keeping the library-specific ways to supply the token. Rename the page to api-token.md, use 'API token' consistently and remove references to the unused .hdxkey file. --- documentation/explanation/facades.md | 10 ++++---- documentation/explanation/information.md | 3 +++ documentation/how-to/api-key.md | 24 ------------------- documentation/how-to/api-token.md | 14 +++++++++++ documentation/how-to/objects.md | 3 +++ .../how-to/operate-resources/datastore.md | 2 +- documentation/index.md | 2 +- documentation/mkdocs.yaml | 2 +- documentation/tutorials/getting-started.md | 12 +++++----- uv.lock | 6 ++--- 10 files changed, 38 insertions(+), 40 deletions(-) delete mode 100644 documentation/how-to/api-key.md create mode 100644 documentation/how-to/api-token.md diff --git a/documentation/explanation/facades.md b/documentation/explanation/facades.md index 6a6aa88..e095b1c 100644 --- a/documentation/explanation/facades.md +++ b/documentation/explanation/facades.md @@ -4,10 +4,12 @@ The easiest way to get started is to use the facades and configuration defaults. facades set up both logging and HDX configuration. The default configuration loads an internal HDX configuration located within the -library, and assumes that there is an API key file called **.hdxkey** in the current -user's home directory **\~** and a YAML project configuration located relative to your -working directory at **config/project_configuration.yaml** which you must create. The -project configuration is used for any configuration specific to your project. +library, and reads the API token from the **HDX_KEY** environment variable or from +**.hdx_configuration.yaml** in the current user's home directory **\~** (see +[Provide your API Token](../how-to/api-token.md)). It also assumes a YAML project +configuration located relative to your working directory at +**config/project_configuration.yaml** which you must create. The project configuration +is used for any configuration specific to your project. The default logging configuration reads a configuration file internal to the library that sets up an coloured console handler outputting at INFO level and a file handler diff --git a/documentation/explanation/information.md b/documentation/explanation/information.md index 6cb3e21..e8bf516 100644 --- a/documentation/explanation/information.md +++ b/documentation/explanation/information.md @@ -7,5 +7,8 @@ This library is part of the [Humanitarian Data Exchange](https://data.humdata.or (HDX) project. If you have humanitarian related data, please upload your datasets to HDX. +For an overview of HDX concepts such as organizations, datasets and resources, see +[HDX core concepts](https://docs.humdata.org/build/overview/hdx-core-concepts). + The code for the library is [here](https://github.com/OCHA-DAP/hdx-python-api). The library has detailed API documentation which can be found in the menu at the top. diff --git a/documentation/how-to/api-key.md b/documentation/how-to/api-key.md deleted file mode 100644 index 567a704..0000000 --- a/documentation/how-to/api-key.md +++ /dev/null @@ -1,24 +0,0 @@ -# Obtain your API Key - -If you just want to read data from HDX, then an API key is not necessary and you can -ignore the 6 steps below. However, if you want to write data to HDX, then you need to -register on the website to obtain an API key. You can supply this key as an argument or -create an API key file. If you create an API key file, by default this is assumed to be -called **.hdxkey** and is located in the current user's home directory **\~**. Assuming -you are using a desktop browser, the API key is obtained by: - -1. Browse to the [HDX website](https://data.humdata.org/) -2. Left click on LOG IN in the top right of the web page if not logged in and log in -3. Left click on your username in the top right of the web page and select PROFILE from -the drop down menu -4. Scroll down to the bottom of the profile page -5. Copy the API key which will be of the form: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -6. You can either: - - a. Pass this key as a parameter or within a dictionary - - b. Create a JSON or YAML file. The default path is - **.hdx_configuration.yaml** in the current user's home - directory. Then put in the YAML file: - - hdx_key: "HDX API KEY" diff --git a/documentation/how-to/api-token.md b/documentation/how-to/api-token.md new file mode 100644 index 0000000..41c8d1c --- /dev/null +++ b/documentation/how-to/api-token.md @@ -0,0 +1,14 @@ +# Provide your API Token + +Reading data from HDX does not need a token. Writing data does. To create one, follow +the instructions in +[HDX core concepts](https://docs.humdata.org/build/overview/hdx-core-concepts). + +Supply the token to the library (called `hdx_key`) in one of these ways: + +1. Pass it as a parameter or within a dictionary +2. Set the `HDX_KEY` environment variable +3. Put it in a JSON or YAML file. The default path is **.hdx_configuration.yaml** in + the current user's home directory **\~**. Then put in the YAML file: + + hdx_key: "HDX API TOKEN" diff --git a/documentation/how-to/objects.md b/documentation/how-to/objects.md index ff1d36f..ebeb0b9 100644 --- a/documentation/how-to/objects.md +++ b/documentation/how-to/objects.md @@ -1,5 +1,8 @@ # Use HDX Objects +HDX data is organised as organizations, datasets and resources. For more about these +concepts, see [HDX core concepts](https://docs.humdata.org/build/overview/hdx-core-concepts). + You can read an existing HDX object with the static **read_from_hdx** method which takes an identifier parameter and returns the an object of the appropriate HDX object type eg. **Dataset** or **None** depending upon whether the object was read eg. diff --git a/documentation/how-to/operate-resources/datastore.md b/documentation/how-to/operate-resources/datastore.md index 86c1bda..0e15079 100644 --- a/documentation/how-to/operate-resources/datastore.md +++ b/documentation/how-to/operate-resources/datastore.md @@ -4,7 +4,7 @@ A resource's data can be loaded into the HDX datastore and queried. HDX calls th [Tabular Data Endpoints (TDE)](https://docs.humdata.org/build/hdx-apis/tabular-data-endpoints), and it is available only for resources with TDE enabled (their `datastore_active` field is true). Contact hdx@un.org to request TDE for your datasets. HDX requires an -API key for all datastore actions and dumps, including reads of public resources, +API token for all datastore actions and dumps, including reads of public resources, and limits each IP address to 60 requests per minute. To create, update or delete the datastore for a resource: diff --git a/documentation/index.md b/documentation/index.md index 101ef93..f8a4960 100755 --- a/documentation/index.md +++ b/documentation/index.md @@ -15,7 +15,7 @@ upload your datasets to HDX. ## How-to Guides - Set up - - [Obtain your API Key](how-to/api-key.md) + - [Provide your API Token](how-to/api-token.md) - [Install the Library](how-to/install.md) - [Build a Docker image](how-to/docker.md) - [Build a project Framework](how-to/framework.md) diff --git a/documentation/mkdocs.yaml b/documentation/mkdocs.yaml index 465a284..ea070bb 100644 --- a/documentation/mkdocs.yaml +++ b/documentation/mkdocs.yaml @@ -15,7 +15,7 @@ nav: - A Quick Example: tutorials/getting-started.md - How-to Guides: - Set up: - - Obtain your API Key: how-to/api-key.md + - Provide your API Token: how-to/api-token.md - Install the Library: how-to/install.md - Build a Docker image: how-to/docker.md - Build a project Framework: how-to/framework.md diff --git a/documentation/tutorials/getting-started.md b/documentation/tutorials/getting-started.md index b781c25..8db5df8 100644 --- a/documentation/tutorials/getting-started.md +++ b/documentation/tutorials/getting-started.md @@ -6,9 +6,9 @@ Let's start with a simple example that also ensures that the library is working properly. In this tutorial, we use virtualenv, a sandbox, so that your Python install is not modified. -1. If you just want to read data from HDX, then an API key is not necessary. However, +1. If you just want to read data from HDX, then an API token is not necessary. However, if you want to write data to HDX, then you need to register on the website to obtain an -API key. Please see [Obtain your API Key](../how-to/api-key.md) about where to find it on the website. Once you have it, then +API token. Please see [Provide your API Token](../how-to/api-token.md) about how to create and supply it. Once you have it, then put it into a file in your home directory: cd ~ @@ -66,8 +66,8 @@ virtualenv if not installed: If you want to write data, then for experimentation, do not use the production HDX server. Instead use the HDX demo server. Assuming you have - an API key for demo stored in a file **.hdxkey** in the current user's home - directory: + an API token for demo stored as **hdx_key_demo** in **.hdx_configuration.yaml** in + the current user's home directory: Configuration.create(hdx_site="demo", user_agent="MyOrg_MyProject") @@ -93,7 +93,7 @@ virtualenv if not installed: url, path = resources[0].download() print("Resource URL %s downloaded to %s" % (url, path)) -13. If you have an API key, you can write to HDX. You can try it out on the demo +13. If you have an API token, you can write to HDX. You can try it out on the demo server. With a dataset to which you have permissions, change the dataset date: dataset = Dataset.read_from_hdx("ID OR NAME OF DATASET") @@ -102,7 +102,7 @@ virtualenv if not installed: print(dataset.get_time_period()) dataset.update_in_hdx() -14. You can view it on HDX before changing it back (if you have an API key): +14. You can view it on HDX before changing it back (if you have an API token): dataset.set_time_period("PREVIOUS DATE") dataset.update_in_hdx() diff --git a/uv.lock b/uv.lock index e9b7c40..140c37b 100644 --- a/uv.lock +++ b/uv.lock @@ -2454,7 +2454,7 @@ wheels = [ [[package]] name = "virtualenv" -version = "21.15.6" +version = "21.15.7" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "distlib" }, @@ -2463,9 +2463,9 @@ dependencies = [ { name = "platformdirs" }, { name = "python-discovery" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/b3/bd/e40ad2df6a9efc1f859ea23d63fd7371cff68252833f182ca9af819bb4d3/virtualenv-21.15.6.tar.gz", hash = "sha256:c8b65c7d206ca6ef18de9352c160b3f04f66fff9f6b0ec8fd31f14688eba52c4", size = 5641659, upload-time = "2026-11-06T18:17:32.46Z" } +sdist = { url = "https://files.pythonhosted.org/packages/55/63/c0a7201eecf36bc273564dd84ed9c5d1464bf2b3b6eb631d3b191e05589c/virtualenv-21.15.7.tar.gz", hash = "sha256:d8c9b23a031c579569159dee7b3f514dd79824ecf1d9201c6e7825cd2abc3a09", size = 5658572, upload-time = "2026-11-17T02:34:47.332Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/0a/63/fd514dee3159f74a96ac01beb8f460b65e4ef0b972f63f4fe9f0cd2aa0e3/virtualenv-21.15.6-py3-none-any.whl", hash = "sha256:4b99ab9b95ff11043939bb4cad2fa0449175fa5a478372864f62160cb6c1a7ed", size = 5680963, upload-time = "2026-11-06T18:17:30.128Z" }, + { url = "https://files.pythonhosted.org/packages/a4/b6/c74f4750852097cce72069b60ab61568121d4bf4988cd09b1dc256d54701/virtualenv-21.15.7-py3-none-any.whl", hash = "sha256:a36fb28c7a21fb8117a2be4183b11176c60c8e31d923bbb2c7426c9ed3e969b3", size = 5721035, upload-time = "2026-11-17T02:34:45.132Z" }, ] [[package]]