API refference

reporting_api_client.client

class reporting_api_client.client.ReportingAPIClient(client_id: str, client_secret: str, api_url: str = 'https://reporting-api.jampp.com/v1/graphql', auth_token_url: str = 'https://auth.jampp.com/v1/oauth/token')[source]

Bases: object

Helper Client to execute requests against Jampp’s Reporting API.

pivot(from_: datetime, to_: datetime, metrics: List[str], dimensions: Optional[List[str]] = None, granularity: Optional[str] = None, filter_: Optional[Dict[str, Dict[str, Any]]] = None, context: Optional[Dict[str, Any]] = None, cohort_type: Optional[str] = None, cohort_window: Optional[timedelta] = None, cleanup: Optional[Dict[str, Dict[str, Any]]] = None) DataFrame[source]

Execute pivot against ReportingAPI.

Parameters:
  • from – Date from which to execute the report. Will be included in the result.

  • to – Date up to which to execute the report. Will not be included in the report.

  • metrics – List of metrics to show on results. If you wish to rename any metric on the result, you should state it on the metric name, example: "open_events: events(event_id: 1)".

  • dimensions – List of dimensions to group by. If you wish to rename any dimension on the result, you should state it on the dimension name, example: "month: date(granularity: MONTHLY)".

  • granularity – Deprecated. Use date(granularity: Granularity!) instead.

  • filter – Define a filter to use against the API. Must follow the structure of Filter. Example: {"appId": {"equals": 10}}

  • context – Define a context to use against the API. Must follow the structure of Context. Example: {"sqlTimeZone": "America/Buenos_Aires"}

  • cohort_type – Define a CohortType to use.

  • cohort_window – Window time delta to use in conjuction with CohortType. Does nothing when cohort_type is not defined.

  • cleanup – Define a cleanup to use against the API. Must follow the structure of Cleanup. Example: {"clicks": {"greaterThan": 10}}

query(query: str, *args, **kwargs) Dict[str, Any][source]

Execute raw query against Reporting API.

to_frame(query: str, *args, **kwargs) DataFrame[source]

Execute query and return results as a Pandas DataFrame.

This method will raise a ModuleNotFoundError if Pandas is not installed. For more information see Installation.

reporting_api_client.client.dict2object(a_dict: Dict[str, Any], render: Optional[Dict[Any, Callable[[Any], str]]] = None) str[source]

Print dictionary as GraphQL object.

Parameters:
  • a_dict – Dictionary to print.

  • render – Define method to render unsupported object types.

reporting_api_client.oauth.transport

Define OAuth transport without session refresh.

class reporting_api_client.oauth.transport.NoRefreshOAuth2Session(*, client, client_secret, auth_token_url, **kwargs)[source]

Bases: OAuth2Session

Won’t really refresh the token but just create a new one.

This is needed because auth.jampp.com, doesn’t support doing token refresh.

refresh_token(*args, **kwargs)[source]

If the credentials expire, then requests_oauthlib.oauth2_session.OAuth2Session is going to call to the refresh URL using the refresh_token grant_type. But that isn’t supported by the auth server, so this changes the logic on the refresh_url to do a new request

class reporting_api_client.oauth.transport.OAuth2Transport(url: str, client_id: str, client_secret: str, auth_token_url: str, headers: Optional[Dict[str, Any]] = None, cookies: Optional[Union[Dict[str, Any], RequestsCookieJar]] = None, use_json: bool = True, timeout: Optional[int] = None, verify: Union[bool, str] = True, retries: int = 0, method: str = 'POST', **kwargs: Any)[source]

Bases: RequestsHTTPTransport

Sync Transport used to execute queries on servers using OAuth.

The transport uses the requests library to send HTTP POST requests.

connect()[source]

Establish a session with the transport.