MerQube IndexAPI + SecAPI client library
Project description
merqube-client-lib
MerQube API Client Library (Python)
Overview
This is a python client library for MerQube's public API.
Project Status
This is a WIP release of an internal client library. This README will be updated when it is ready. More functionality will be added here over the coming weeks.
Full Specification
A link-resolved OpenAPI spec is served from here, and the raw YAML (unresolved, i.e., it contains remote references to other YAML) is served from here. There is a browsable rendering of the OpenAPI (formerly Swagger) spec here.
Installation and requirements
This library can be installed from PyPi:
pip install merqube-client-lib
It is currently python3.10+.
API Concepts
Main endpoints:
MerQube's public API has the following main components:
- IndexAPI (
/index): endpoints for managing index objects themselves (creation, deletion, and editing of indices), and also collecting some types of index information (e.g., portfolios). - SecAPI (
/security): endpoints for collecting security metrics from indices and other security types. For example, daily returns and available intermediate calculations. - Apikey (
/apikey): an API for managing API keys, which are used by this client (or as acurlheader etc.) to authenticate as a user
Permissions
While endpoints on api.merqube are publicly available, many of the resources are permissioned and require authorization to view (as discussed further below).
All objects in MerQube's universe are in a namespace, and MerQube's API is permissioned by namespace.
Objects in the default namespace are public and world-readable; for example, all indices served on api.merqube.com/index that can be seen without authentication.
Typically, these are MerQube branded indices.
Customer indices are typically in customer namespaces, and clients from those organizations have permissions to view those namespaces.
For example, clients from MyBank may be permissioned to the mybank namespace - when they query api.merqube.com/index, they will see the combination of all default (open) indices and all indices in mybank. There may be multiple namespaces per client.
Names vs. IDs
There are several standard properties on every object in the MerQube API, most notably:
name: a name chosen by the user (on creation) that is unique across that resource type, e.g., no two indices have the same namenamespace: the permissioning namespace described aboveid: an unchanging identifier for that index. While index names can be changed, identifiers cannot. They are permanent references to the object, which is why all API endpoints are UUID based (though you can search by name). The only way to "change" the id of an object is to delete it, and make another with the same name.status: a metadata block containing information about creation and edit times. This block also serves as a token when making edits. It must be supplied onPUTorPATCH, and the write is only accepted if the status block matches the current object in storage (i.e., it verifies you are updating the current object and not an outdated copy).
Index vs. Index-securities
Creating an Index in MerQube's API with name X in namespace Y, automatically creates two securities in the SecAPI:
- An
indexsecurity that holds all returns and metrics for that index - An
intraday_indexsecurity for the same, except that it will only have metrics if the index is a real time index.
These securities, located on the SecAPI (/security/index and /security/intraday_index respectively), will have different IDs than the index, but have the same name X and namespace Y as the index.
They all move in unison; if the index name or namespace is changed, the name and namespace of its linked securities also change to match.
Types
MerQube makes heavy use of pydantic
The script ./generate_types.sh at the root of this repo will:
- Pull down the latest production API (OpenAPI spec)
- generate a file `merqube_client_lib/pydantic_types.py
We may eventually push this as a package to PyPi as well.
Note, we use a third party tool to generate this, and other than the CLI options, do not have control over the layout or ordering of this file.
These types can then be used as classes in any code forming indices (finally, using pydantic's .json or .dict method to convert before sending to the API).
The most relevent types to clients are probably:
IndexDefinitionPost: the schema for new index creation (POST)IndexDefinitionPatchPutGet: the schema for the return fromGETs, and what would be supplied onPUTandPATCH. This model contains server side generated fields likeStatusthat are illegal onPOST.SecurityMetrics: the schema for every record in the SecAPI. This is what can be expected on all reads.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file merqube_client_lib-0.10.0.tar.gz.
File metadata
- Download URL: merqube_client_lib-0.10.0.tar.gz
- Upload date:
- Size: 32.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.2 Linux/5.15.0-1030-aws
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5e23fac981154f2c33b04350e547eddd073b3c656db63beb3323230e62f30bd
|
|
| MD5 |
7c0f8857852b2857f7e9fa68543fa80e
|
|
| BLAKE2b-256 |
74e5002d3f9beb46bac25bc1e289df02dfee92a95136e696a66aba6b4732f6f1
|
File details
Details for the file merqube_client_lib-0.10.0-py3-none-any.whl.
File metadata
- Download URL: merqube_client_lib-0.10.0-py3-none-any.whl
- Upload date:
- Size: 43.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.2 Linux/5.15.0-1030-aws
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59848c54084fa80d9c7a32b1b016186a9660bff08285d712be51fb25bde557a7
|
|
| MD5 |
c13dfdca7e7202aa9fcadde206ce1a02
|
|
| BLAKE2b-256 |
8dd8376aee4112c5f982a0c8102564362e6ffe65801b3abd5fc4ca4ee02331a7
|