Skip to main content

CanAPI

License Build Status Documentation Status Stars

A universal client api generator. To learn more about the design and how to use please read our documentation

Installation

Install canapi from PyPi using:

pip install canapi

Making a ClientAPI

You can get started by using one of the client apis in our registry. Before running the following code, you must go to polygon and obtain a free api key.

import canapi as cp

polygon = cp.api("polygon", params={"apiKey": POLYGON_API_KEY})

data = polygon.reference.news(url_params={"symbol": "AAPL"})[0]

print(data)
{'symbols': ['AAPL'], 'timestamp': '2020-03-26T23:52:51.000Z', 'title': 'Apple (AAPL): Despite Likely iPhone 12 Delays, the Risk-Reward Remains Compelling, Says Analyst', 'url': 'https://fin
ance.yahoo.com/news/apple-aapl-despite-likely-iphone-235251688.html', 'source': 'finance yahoo', 'summary': 'When considering the fortunes of the FAANG family since the viral outbreak, it ap
pears Apple (AAPL) has most to lose. Amazon and Netflix can count their internet driven models as particularly well set up for a hibernation period. And while Google and Facebook stand to lo
se significant advertising revenue', 'image': 'https://s.yimg.com/uu/api/res/1.2/Su.8VniRbi_GL2B3BruK5w--~B/aD0zMzc7dz0xMDI0O3NtPTE7YXBwaWQ9eXRhY2h5b24-/https://media.zenfs.com/en-US/smarter
analyst_347/6909df17d6ef3af25ac79e2e6c0078d5', 'keywords': ['aapl']}

You can also practice making your own client by finding a rest api and trying to make a configuration for it. For example, using httpbin the following client can be made.

httpbin = cp.from_config({
    "name": "httpbin",
    "uri": "https://httpbin.org",
    "endpoints": {
        "anything": {
            "get": {
                "method": "get",
                "path": "/anything"
            },
            "post": {
                "method": "post",
                "path": "/anything"
            },
            "put": {
                "method": "put",
                "path": "/anything"
            }
        }
    }
})

print(httpbin.anything.get(params={"p0": 0}))

Contributors

Here are some good ideas for contributions to the library:

  • Adding more configuration files to the registry
  • Building tools for converting OpenAPI yaml files into usable json files
  • Building tools for scraping api documentation and generating configuration files

If you can think of more, then create a new issue!

Metadata

Release files for canapi 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for canapi 0.0.3
File Size Uploaded Provenance Actions
canapi-0.0.3.tar.gz 8.4 kB Without provenance Details for canapi-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for canapi 0.0.3
File Interpreter ABI Platform Actions
canapi-0.0.3-py3-none-any.whl Python 3 none any Details for canapi-0.0.3-py3-none-any.whl

Total release size: 20.9 kB

Release files / canapi-0.0.3.tar.gz

Download URL canapi-0.0.3.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
73a773cbedbd098fc57af2b74bac54a03b3e1a5bd3d0e0ff0f319ab036d82b3d
BLAKE2b-256 checksum
How to use checksums
2cf8c550645c046326f3da1ca4547a4306663edc5f4cb52ae242d6df308539c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9

Release files / canapi-0.0.3-py3-none-any.whl

Download URL canapi-0.0.3-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f156ca4e03c563b53da8b562a53ccd0abc71a98be9d12dc40413599aacf01a8
BLAKE2b-256 checksum
How to use checksums
2c8195e724e0a4e81faedc940a61b2ab94f23da4be59bcb634e3ba7be7f3fe9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9

Security for canapi 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page