Skip to content

Latest commit

 

History

History
130 lines (98 loc) · 4.45 KB

README.md

File metadata and controls

130 lines (98 loc) · 4.45 KB

Traject Data logo

traject-data-py

Traject Data • trajectdata.com • SERP Data API • SERP Data API for Scale | Locale SEO | Agencies | Brands

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 0.1.0
  • Package version: 0.1.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit https://support.authoritylabs.com

Acount Setup

  • Visit trajectdata.com to create account
  • Authentication Token for API usage is displayed on account dashboard
  • New accounts are provided $5.00 in credits to test with

Requirements.

Python >= 3.6

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/authoritylabs/traject-data-py.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/authoritylabs/traject-data-py.git)

Then import the package:

import traject_data

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import traject_data

Getting Started

Please create an account, follow installation procedure and using the API is straightforward:

Post your keyword to search by

from pprint import pprint
import traject_data
from traject_data.api import serp_api

config = traject_data.Configuration(
    api_key={"ApiKeyAuth": 'YOUR_API_KEY'}
)

with traject_data.ApiClient(configuration) as api_client:
    api = serp_api.SerpApi(api_client)
try:
    #post your search
    #the result will be delivered to your endpoint asynchronously
    #typical delilvery may take a few minutes
    #post_keyword_priority can be used for speedier delivery times (increased costs apply)
    response = api.post_keyword(keyword='restaurants near me', #required
                                engine='google', #defaults to google if not provided
                                locale='en-us', #defaults to en-us if not provided
                                geo='seattle, wa', #optional feature
                                mobile=False, #defaults to False if not provided
                                param_callback='YOUR_CALLBACK_ENDPOINT') #callback required if not configured globally for your account
    pprint(api_response)
except traject_data.ApiException as e:
    print("Error: %s\n" % e)

Your callback endpoint is notified

#Callback example implemented in Flask (substitute your preferred web framework)
from flask import Flask
import traject_data
from traject_data.api import serp_api

app = Flask(__name__)

config = traject_data.Configuration(
    api_key={"ApiKeyAuth": 'YOUR_API_KEY'}
)
api_client = traject_data.ApiClient(configuration) as api_client:
api = serp_api.SerpApi(api_client)

@app.route('/callback', methods['POST'])
def notify():
    notify_json = request.get_json()
    #fetch the serp parsed json
    json_response = api.get_serp(notify_json['json_id'])
    #fetch the serp html
    html_response = api.get_serp_html(notify_json['html_id'])

Serp formats

Documentation for API Endpoints

All URIs are relative to https://api.trajectdata.com

Class Method HTTP request Description
SerpApi get_engine_locale GET /supported/{engine}/{locale}.json Locale details for a given engine
SerpApi get_locales GET /supported/{engine}.json Fetch supported locales for a given engine
SerpApi get_serp GET /keywords/get.json Fetches SERP json
SerpApi get_serp_html GET /keywords/get.html Fetches SERP html
SerpApi post_keyword POST /keywords Create keyword search
SerpApi post_keyword_priority POST /keywords/priority Priority create keyword search

Contact

[email protected] | [email protected]