Overview

The abstract-python library is a Python SDK for APIs by AbstractAPI. It contains helper classes that allow Python developers use these APIs without having to know the endpoints off-hand.

It also does type validation on each request data before they are sent to the API server. This helps to manage credits, as each request costs a credit - whether successful or otherwise.

This SDK currrently supports the Exchange Rates API, IP Geolocation API, and the VAT API.

This is not an official SDK by AbstractAPI but safe to use by anyone.

Quickstart

Format for responses

All responses are returned as a JSON object. Each response object has a status field that contains the response status code. Below is a sample response object for a successful request:


{
  // Other response data
  "status": 200
}

The status field is used to verify the request’s success.

Errors and exceptions

Errors in abstract-python are in two(2) variants.

  • Regular Python exceptions:

A common exception you will encounter is the TypeError, usually from wrong data types used in arguments.

  • JSON error messages:

These are JSON objects with detailed description of the error. They are often self-explanatory. Below is a sample error message:

// Authorization error

{
  "error": {
    "message":"A validation error occurred.",
    "code":"validation_error",
    "details":{
      "api_key":["This field may not be blank."],
      "country_code":["\"fu\" is not a valid choice."]
    }
  },
  "status": 401
}

More details on errors in each API section.