Python integration to DataAetherScan
Project description
DataAetherScan
dataaetherscan is a Python package that facilitates interaction with the DataAetherScan API. It provides methods for authentication and access to various API resources such as users, channels, jobs, and credits.
Installation
Install the package using pip with the following command:
pip install dataaetherscan
Usage
First, you need to create a DataAetherScan object with your credentials:
from dataaetherscan import DataAetherScan
das = DataAetherScan("yourEmail@example.com", "yourPassword")
Authentication
Authentication is automatically performed upon instantiation:
das.authenticate()
API Methods
After successful authentication, you can access various API endpoints:
Retrieve User Information
user_info = das.get_user()
print(user_info)
Retrieve Channel List
channels = das.get_channels()
print(channels)
Retrieve Credit Information
credit_info = das.get_credit()
print(credit_info)
Retrieve and Manage Jobs
-
Retrieve all jobs:
jobs = das.get_jobs() print(jobs)
-
Retrieve a specific job:
job = das.get_job(job_id) print(job)
-
Create a new job:
job_data = {'name': 'Job1', 'description': 'Data processing'} new_job = das.create_job(job_data) print(new_job)
-
Delete a job:
response = das.delete_job(job_id) print(response)
Error Handling
The methods can raise a ValueError if there are issues with the API request. Make sure to handle your requests within try-except blocks:
try:
user_info = das.get_user()
except ValueError as e:
print("An error occurred:", e)
Creating a Job with DataAetherScan
This section outlines how to properly configure and send a request to create a job using the dataaetherscan API. A job is a task submitted to the API that involves tracking certain products across different channels and countries.
Job Data Structure
To create a job, you need to specify details about the channels, country codes, and products. Here’s the structure of the data required:
job_data = {
"channel": "Google",
"country_code": "DE",
"products": [
{
"sku": 1,
"gtin_ean": "761856508385"
}
]
}
Parameters
- channel: (string) The name of the channel where the products will be tracked.
- country_code: (string) The ISO country code where the channel is located.
- products: (list of dictionaries) A list of products to be tracked, each with specific attributes.
Product Attributes
Each product dictionary may contain the following fields:
- sku: (string, required) The stock keeping unit or identifier for the product.
- gtin_ean: (string, optional) The global trade item number or European article number of the product.
- title: (string, optional) The title or name of the product.
Validation Rules
The job creation involves several validation steps to ensure the integrity of the data:
-
Product Validation:
- At least one of
gtin_eanortitlemust be present along withsku. - If neither
gtin_eannortitleis provided, a validation error will be raised, indicating that at least one of these fields is required.
- At least one of
-
Job Serializer Validation:
- Products must be provided as a list of dictionaries.
- An empty list of products is not allowed.
- Each product's data is validated individually.
Creating a Job
To create a job, use the create_job method of your DataAetherScan instance:
das = DataAetherScan("yourEmail@example.com", "yourPassword")
try:
new_job = das.create_job(job_data)
print("Job created successfully:", new_job)
except ValueError as e:
print("An error occurred while creating the job:", e)
Error Handling
Handle potential errors during the job creation process to manage situations where the input data might not meet the API requirements:
- Use try-except blocks to catch exceptions, particularly
ValueError, which indicates a problem with the job data or an API request failure.
This guide provides a comprehensive overview of the requirements and steps to create a job using the dataaetherscan package, ensuring that all data complies with the underlying API's validation rules.
Contributing
Improvements and pull requests are welcome! Please ensure that you follow existing code styles and practices.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dataaetherscan-1.0.0.tar.gz.
File metadata
- Download URL: dataaetherscan-1.0.0.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54dea6ecdc60dbb241086a5865c307e092763a512cb57b442d22a3eec3ebc88b
|
|
| MD5 |
38af77af2e56047324e0841d00e87290
|
|
| BLAKE2b-256 |
7975aad985223b3963e26162a10644dbc69dd078fc2d8d2ced22c223aa155d2a
|
File details
Details for the file dataaetherscan-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dataaetherscan-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
179a8fa80d5ca7ccfaa8bdfce6c35fa3318419960ac249745c61922e29009ab2
|
|
| MD5 |
fb6dc050445d3a19def5a5bb8ca50b31
|
|
| BLAKE2b-256 |
3b975368cc1b930cd7431feb097c69dd097509c42e8f7fdd5d1dca798e942349
|