Skip to content

Changing the Configuration

There are several ways to change the values of the settings listed on the previous page:

  1. Place a file named .halchemy in your home directory.
  2. Place a file named .halchemy in your project's root directory.
  3. When creating an Api object, pass the "base URL" and "headers" as arguments.
  4. After creating an Api object, use properties to change the settings.
  5. When making a request, you can add headers to just that request.

Each of these ways is overridden by the next. That is, a value in your home directory's .halchemy file will be overridden if that value is in the .halchemy file in your project's root directory, and so on down the list.

Configuration File

The .halchemy file follows the format of any INI file as follows (each section and each value is optional):

ini
[halchemy]
base_url = http://example.org/api
parameters_list_style = index
etag_field = _etag

[headers]
Cache-control = no-cache
Accept-Language = en-CA,en;q=0.9,fr-CA;q=0.5,fr;q=0.3

[error_handling]
raise_on_network_error = False
raise_on_status_codes = 400-403, >404

NOTES

  • all section names and settings names are in snake_case, no matter what language you are using.
  • any headers you set this way are merged with the default headers. To remove a default header you must use the Api's "remove headers" function (see Request Headers for more details).

Configuration Properties

Here is how you can change a settings after creating an Api object, using the base url setting as an example:

Released under the MIT License.

Released under the MIT License.