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

PyPI - Version PyPI - Python Version Downloads

Tests Issues Stargazers MIT License


Logo

MagicalAPI Python Client

An Async and Type Annotated Python Client to Easy Access MagicalAPI.com Service.
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 careers and data insights, Your ultimate tool for 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 parse a resume using Resume Parser service:

import asyncio

from magicalapi.client import AsyncClient
from magicalapi.errors import APIServerError, APIServerTimedout
from magicalapi.types.base import ErrorResponse

resume_url = (
    "https://resume-resource.com/wp-content/uploads/00123-sales-professional-resume.pdf"
)
output_file_name = "resume_parser.json"


async def main():
    try:
        # the api_key will load from the .env file
        async with AsyncClient() as client:
            response = await client.resume_parser.get_resume_parser(url=resume_url)

            if isinstance(response, ErrorResponse):
                # got error from api
                print("Error :", response.message)
            else:
                # got response successfully
                print("credists :", response.usage.credits)
                # save response in json file
                with open(output_file_name, "w") as file:
                    file.write(response.model_dump_json(indent=3))

                    print(f"response saved to {output_file_name}")
    except (APIServerError, APIServerTimedout) as e:
        # handling server errors
        print(e)
    except Exception as e:
        print("An error occurred:", str(e))


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.2.0.post2.tar.gz (84.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

magicalapi-1.2.0.post2-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file magicalapi-1.2.0.post2.tar.gz.

File metadata

  • Download URL: magicalapi-1.2.0.post2.tar.gz
  • Upload date:
  • Size: 84.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for magicalapi-1.2.0.post2.tar.gz
Algorithm Hash digest
SHA256 933f9ef002f6fd1fbe57cc4d3d76ceb0708fa7ff066d268df2e2745011899b62
MD5 77f2d50832fa8a22e1893056277c49b2
BLAKE2b-256 63e03390eda092314ec78afb5c74e35ff369991076b22d2712ec71a69fe3068b

See more details on using hashes here.

File details

Details for the file magicalapi-1.2.0.post2-py3-none-any.whl.

File metadata

File hashes

Hashes for magicalapi-1.2.0.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 2efc27ac6f54a89b62bf9180b31d4a0f41e37411cf110cd82afe75a74243bdbf
MD5 5c75bfdcc75e28958e7fdc4e56b8e6fc
BLAKE2b-256 5e2e5b778f6c309173f221b88561a9fe1a7bbd72b857e994e907699c5f4d4edf

See more details on using hashes here.

Supported by

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