Skip to main content

This is a Python client that provides easy access to the MagicalAPI.com services, fully type annotated, and asynchronous.

Project description

Tests PyPI - Version PyPI - Python Version

Contributors Forks Stargazers Issues MIT License


Logo

MagicalAPI Python Client

An Async and Type Annotated Python Client to Easy Access MagicalAPI.com Service.
View Demo · Report Bug · Request Feature

Table of Contents
  1. What is MagicalAPI
  2. About The Project
  3. Getting Started
  4. Usage
  5. Contributing
  6. License

What is MagicalAPI?

MagicalAPI is your AI edge in content and careers, Your ultimate tool for YouTube SEO, Resume Parsing, LinkedIn data and more.


About The Project

This is a Python client that provides easy access to the MagicalAPI.com services, fully type annotated, and asynchronous.

(back to top)

Built With

Pydantic

(back to top)

Getting Started

This is an example of how you can install the client and use it in your own scripts and projects.

Installation

Install package using pip

pip install magicalapi

(back to top)

Usage

here are some samples of how to use the client for each service. At first, you have to create an object of AsyncClient like this:

from magicalapi.client import AsyncClient

API_KEY = "mag_123456"
client = AsyncClient(api_key=API_KEY)

You can pass the API_KEY on the code, or put it on a .env file and the client will read from there.

Config .env File

Example of using .env file, all settings start with the prefix MAG_ and are case insensitive, so MAG_EXAMPLE, Mag_example, and mag_EXAMPLE are equal.

# .env

MAG_API_KEY="mag_1234567"

So now you can leave api_key parameter empty.

from magicalapi.client import AsyncClient

client = AsyncClinet()

Here is an example of how to get keywords of Youtube Top Keywords service:

import asyncio
from magicalapi.client import AsyncClient
from magicalapi.types.base import ErrorResponse

search_sentence = "chatgpt 4 turbo" # your search sentence to get keywords related to
country = "1" # use get_countries method to see countries codes (Default = 1 : WorlWide)
language = "1000" # use get_languages method to see countries codes (Default = 1000 : English)


async def main():
    # the api_key will load from the .env file
    async with AsyncClient() as client:
        # Get YouTube keywords
        keywords_response = await client.youtube_top_keywords.get_keywords(
            search_sentence=search_sentence,
            country=country,
            language=language,
        )
        if type(keywords_response) == ErrorResponse:
            # got error from API
            print("Error :", keywords_response.message)
        else:
            # got response successfully
            print("credits :", keywords_response.usage.credits)
            print("keywords count :", len(keywords_response.data.keywords))

            # save response in JSON file
            with open("keywords_response.json", "w") as file:
                file.write(keywords_response.model_dump_json(indent=3))


        # get languages list
        # languages = await client.youtube_top_keywords.get_languages()
        # get countries list
        # countries = await client.youtube_top_keywords.get_countries()


asyncio.run(main())

All of the methods in the client have type hints and help to simply use.

For full examples, please see the Examples Directory

(back to top)

Contributing

Contributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

Here is the Contributing Guidelines. Don't forget to give the project a star! Thanks again!

(back to top)

License

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

(back to top)

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

magicalapi-1.0.1.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

magicalapi-1.0.1-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file magicalapi-1.0.1.tar.gz.

File metadata

  • Download URL: magicalapi-1.0.1.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.8 Linux/6.8.2-arch2-1

File hashes

Hashes for magicalapi-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f3e3c7210ac8a4808b6f57cce97d691ef3ea68d09c6d631f8bea4483d8959b18
MD5 76c85c16b676604f0578aa8c1f4d4503
BLAKE2b-256 6a01623af2c52c99d660459f73e8e9388267663731b8518d7642d715fa16bdfd

See more details on using hashes here.

File details

Details for the file magicalapi-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: magicalapi-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.8 Linux/6.8.2-arch2-1

File hashes

Hashes for magicalapi-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1476234ba5fe931e9e6a9f328b607adfa48a51a7f91e0f63c848b6f52c906cd2
MD5 4198cd8c42b99c8ef370bafc83c1904b
BLAKE2b-256 4b6b78cdb579d2c762e22e1b40ed0ecedbb407c1e0af1e091495fcfbc736c215

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