apteco-api-0.2.1


توضیحات

Apteco API
ویژگی مقدار
سیستم عامل -
نام فایل apteco-api-0.2.1
نام apteco-api
نسخه کتابخانه 0.2.1
نگهدارنده []
ایمیل نگهدارنده []
نویسنده Apteco Ltd
ایمیل نویسنده support@apteco.com
آدرس صفحه اصلی https://www.apteco.com/
آدرس اینترنتی https://pypi.org/project/apteco-api/
مجوز Apache 2.0
# apteco-api A wrapper package for the Apteco API to allow access to Apteco Marketing Suite™ resources This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: v2 - OrbitAPI spec version: 1.8.13.2139 (with edits) - Package version: 0.2.1 - Build package: `org.openapitools.codegen.languages.PythonClientCodegen` ## Requirements - Python 2.7 and 3.4+ - Access to an installation of the Apteco API The Apteco API, which also goes under the name **Orbit API**, is part of the Apteco Orbit™ installation. If you are unsure whether you have access to this, please contact Apteco support (support@apteco.com). *Note: the examples in this guide use Python 3.6+* ## Installation & Usage You can install the package the usual way from PyPI using `pip`: ``` pip install apteco-api ``` Import the package in Python using: ```python import apteco_api ``` *Note: the package follows the Python convention of a hyphen `-` in the package name and underscore `_` in the import name.* ## Getting Started The examples below shows how to connect to the API, log in to create an access token, retrieve some data from one of the API's endpoints, and then log out. *Note: your login credentials (`my_username` and `my_password` below) are the same credentials you would use to log in to your FastStats system or Apteco Orbit™.* ### Logging in ```python import apteco_api as aa # configure the API client to use your instance of the API config = aa.Configuration(host='https://example.com/OrbitAPI') api_client = aa.ApiClient(configuration=config) # send a simple login request sessions_controller = aa.SessionsApi(api_client) login_response = sessions_controller.sessions_create_session_simple( 'my_data_view', 'my_username', 'my_password' ) # keep a copy of the session ID (needed to log out) session_id = login_response.session_id # update the configuration with your credentials config.api_key={'Authorization': login_response.access_token} config.api_key_prefix={'Authorization': 'Bearer'} ``` Since the `config` object updated here is the configuration object for `api_client`, the latter will now be authorised to access the API. ### Retrieving data from an endpoint This code retrieves a list of tables in the `Holidays` system on the given DataView: ```python tables = aa.FastStatsSystemsApi(api_client).fast_stats_systems_get_fast_stats_tables( 'my_data_view', 'holidays' ) print(f"There are {tables.count} tables in the Holidays system:") print('\n'.join(t.name for t in tables.list)) ``` **Output:** ```commandline There are 9 tables in the Holidays system: Households People Bookings Communication Responsible Insurance Communications Content Responses Attributed Journey History ``` ### Logging out You can end your session using the `logout_session` endpoint, and passing in the session ID returned from the logging in process above: ```python aa.SessionsApi(api_client).sessions_logout_session('my_data_view', session_id) try: tables = aa.FastStatsSystemsApi(api_client).fast_stats_systems_get_fast_stats_tables( 'my_data_view', 'holidays' ) except aa.ApiException as e: print(f"{e.status}: {e.reason}") ``` **Output:** ```commandline 401: Unauthorized ``` The first line successfully ended the session and so, as expected, the attempt to retrieve the tables data failed and raised an exception. Note that logging out like this ends the session on the server-side, but it doesn't remove the copy of the (now invalid) access token kept in the `api_client.configuration` object. ## General use of the API client Every section of the API (`Audiences`, `FastStatsSystems`, `Queries`, `Sessions`, etc) has a corresponding controller class in the `apteco-api` package, named `<section>Api` e.g. `SessionsApi`, as seen above. To use endpoints from a given section, create an instance of the controller by passing an \[authorised\] `ApiClient` object as the single argument to its constructor: ```python queries_controller = aa.QueriesApi(api_client) ``` This object then has a method corresponding to each endpoint of that section of the API, which can be called as a normal Python function. ```python query_result = queries_controller.queries_perform_query_file_count_synchronously( 'my_data_view', 'holidays', query_file=aa.QueryFile('Private/Bookings to France or Germany.xml') ) ``` Some of the parameters for this function may need to be specific object types; in the example here, the first two parameters are strings specifying the DataView and FastStats system to use for the query, while the path of the file for the query is given via a `QueryFile` object supplied as a keyword-only argument. The `QueryFile` object itself is initialised with a single argument, namely the filepath. Similarly, the function call returns a Python object. These API functions often return 'result' objects which bundle together various data and metadata as attributes, and these attributes can then be accessed to obtain the information of interest. ```python count = query_result.counts[0] print(f"The query matched {count.count_value:,} {count.table_name.lower()}.") ``` **Output:** ```commandline The query matched 985,734 bookings. ``` ### Further details All classes and methods have detailed docstrings providing further information about their parameters and return values. You can also explore the API in a visual way by going to `/swagger/ui/index.html` from your API base URL, e.g. `https://example.com/OrbitAPI/swagger/ui/index.html` Here, each section of the API is listed, and clicking on one will expand the view to show all the endpoints that belong to it. Clicking on an endpoint will similarly expand that to detail its parameters and show example values for using it. You can also try out endpoints directly within the interface, and view the returned data. ## Author Apteco Ltd support@apteco.com


نیازمندی

مقدار نام
>=1.15 urllib3
>=1.10 six
- certifi
- python-dateutil


نحوه نصب


نصب پکیج whl apteco-api-0.2.1:

    pip install apteco-api-0.2.1.whl


نصب پکیج tar.gz apteco-api-0.2.1:

    pip install apteco-api-0.2.1.tar.gz