Oct 10, 2024
Photo by Brecht Corbeel on Unsplash
The SharpAPI Python Client SDK bridges the gap between your Python applications and SharpAPI's robust AI-powered services.
By leveraging this SDK, Python developers can effortlessly incorporate advanced functionalities such as sentiment analysis, content generation, data categorization, and more, without delving deep into complex API integrations.
Check the Python SDK directly at Python Package Index ➺ PyPI.org
For Python developers looking to dive into SharpAPI, our SharpAPI Python Test Suite on GitHub is the perfect starting point. This repository offers hands-on code samples and use case examples, covering a wide range of SharpAPI's powerful capabilities, from resume parsing to SEO tag generation. With step-by-step instructions and an interactive CLI, developers can easily test out functionalities, simulate diverse workflows, and integrate AI-powered automation into their Python projects faster. Check it out and explore the potential of SharpAPI's Python SDK to streamline your development process today!
The SharpAPI Python Client SDK is packed with features designed to cater to multiple sectors:
Getting started with the SharpAPI Python Client SDK is quick and easy. You can install it via PyPI using pip
or through Poetry for dependency management.
pip install sharpapi-python-client
poetry add sharpapi-python-client
To use the SDK, you need an API key from SharpAPI. If you haven't already, sign up at SharpAPI.com and obtain your unique API key.
For security and convenience, it's best to store your API key in an environment variable. Create a .env
file in your project's root directory:
SHARP_API_KEY=your_sharpapi_api_key_here
Ensure that .env
is included in your .gitignore
to prevent accidental exposure of your API key.
The SDK utilizes python-dotenv
to load environment variables. Initialize it in your application before using the SDK:
from dotenv import load_dotenv
load_dotenv() # Loads environment variables from .env file
The SharpAPI Python Client SDK offers a straightforward interface to interact with various SharpAPI endpoints. Below are examples demonstrating how to utilize some of its key functionalities.
from sharpapi import SharpApiService
# Initialize the SharpApiService with your API key
sharp_api = SharpApiService(api_key='YOUR_SHARP_API_KEY')
try:
# Generate Product Categories
status_url = sharp_api.product_categories(
product_name='Lenovo Chromebook Laptop (2023), 14" FHD Touchscreen Slim 3, 8-Core MediaTek Kompanio 520 CPU, 4GB RAM, 128GB Storage',
language='German', # Optional
max_quantity=400, # Optional
voice_tone='Neutral', # Optional
context='Optional current e-store categories' # Optional
)
# Fetch and print the results
result_sharp_api_job = sharp_api.fetch_results(status_url)
print(result_sharp_api_job.get_result_json())
except Exception as e:
print(f"An error occurred: {e}")
from sharpapi import SharpApiService
# Initialize the SharpApiService with your API key
sharp_api = SharpApiService(api_key='YOUR_SHARP_API_KEY')
try:
# Parse Resume
status_url = sharp_api.parse_resume(
file_path='path/to/sample_resume.pdf',
language='English' # Optional
)
# Fetch and print the parsed resume data
parsed_resume = sharp_api.fetch_results(status_url)
print(parsed_resume.get_result_json())
except Exception as e:
print(f"An error occurred: {e}")
from sharpapi import SharpApiService
# Initialize the SharpApiService with your API key
sharp_api = SharpApiService(api_key='YOUR_SHARP_API_KEY')
try:
# Analyze Sentiment
review_text = "This product exceeded my expectations! Highly recommended."
status_url = sharp_api.product_review_sentiment(review_text)
# Fetch and print the sentiment analysis results
sentiment_result = sharp_api.fetch_results(status_url)
print(sentiment_result.get_result_json())
except Exception as e:
print(f"An error occurred: {e}")
Happy Coding! 🚀