Skip to main content

A Python package for interacting with SERP API

Project description

Python API client for SERP API


For your convenience, you can make API calls using sync or async (asyncio) interface.

Installation

pip install serp

Note that it is always recommended pinning version of your installed packages.

Usage example (sync)

An example of how to create an origin:

from serp import Client


if __name__ == '__main__':
    # api_token is just str with your API token
    api_token = "abcd012345"
    # Now create instance of Client. There should be only one per process.
    client = Client(base_url="http://localhost:8080", api_token=api_token)
    # Issue API request to create an origin
    client.origins.create(name="test_name")

Now that we have our origin created, we can create profile inside that origin:

from serp import Client


def create_profiles_example(client: Client):
    origin_id = 1  # you can inspect response from `client.origins.create`
    with open("image.png", "rb") as f:
        response = client.profiles.create(
            image=f,
            origin_id=origin_id
        )
    print("Profiles Create Response:\n", response.json(), flush=True)


if __name__ == '__main__':
    # api_token is just str with your API token
    api_token = "abcd012345"
    # Now create instance of Client. There should be only one per process.
    client = Client(base_url="http://localhost:8080", api_token=api_token)
    # Issue API request to create a profile
    create_profiles_example(client)

Now that we have our origin & profile created, we can search for profile:

from serp import Client


def search_profiles_example(client: Client):
    with open("image.png", "rb") as f:
        response = client.profiles.search(
            image=f,
            identify_asm=True
        )
    print("Profiles Search Response:\n", response.json(), flush=True)


if __name__ == '__main__':
    # api_token is just str with your API token
    api_token = "abcd012345"
    # Now create instance of Client. There should be only one per process.
    client = Client(base_url="http://localhost:8080", api_token=api_token)
    # Issue API request to search profiles
    search_profiles_example(client)

For more examples and usage, please refer to the docs.

Development setup

To install all the development requirements:

pip install --upgrade pip
pip install poetry
poetry install --no-root

To run linters & test suite:

./scripts/test.sh

How to release

  1. Update version in:
    • CHANGELOG.md
    • __init__.py
    • pyproject.toml
  2. Lock deps to update version in poetry: poetry lock
  3. Get API Token from account settings in PyPI
  4. poetry config pypi-token.pypi YOUR_API_TOKEN
  5. poetry build
  6. poetry publish

Release History

  • 0.1.4
    • Changed name to SERP
    • Minor fixes
  • 0.1.1
    • Fixed types of custom Enum classes and in corresponding methods
  • 0.1.0
    • Initial version of package

License

Distributed under the MIT license. See LICENSE for more information.

Contributing

  1. Create your feature branch (git checkout -b feature/fooBar)
  2. Commit your changes (git commit -am 'Add some fooBar')
  3. Push to the branch (git push origin feature/fooBar)
  4. Create a new Pull Request

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

serp-0.1.4.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

serp-0.1.4-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file serp-0.1.4.tar.gz.

File metadata

  • Download URL: serp-0.1.4.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.8 Darwin/22.6.0

File hashes

Hashes for serp-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e0bc8a33e21ae3f1e04244ba4fb9913759b4c069ea92c107003c8b0027e6049d
MD5 7d1166ffa3dca83caf81b0bf02872bf4
BLAKE2b-256 ca3c7aa9ca10a1608c7a818efb8903f9eed4c22c9718066f98e39c9e88223acc

See more details on using hashes here.

File details

Details for the file serp-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: serp-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.8 Darwin/22.6.0

File hashes

Hashes for serp-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 069189d8891afb91a8ea175cccc55c3ab224be74fa40a036f228f158c80d9cc7
MD5 ea00b394224e4e1ec5341872737aae44
BLAKE2b-256 96de2ada50c4aed5c40403bbd54b7d0ef8536c622714dd53d2e90f069fea8df1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page