Giter VIP home page Giter VIP logo

pytunes-reporter's Introduction

pyTunes Reporter

https://travis-ci.org/gifbitjapan/pytunes-reporter.svg?branch=master https://coveralls.io/repos/github/gifbitjapan/pytunes-reporter/badge.svg?branch=master

A Python Framework for Getting Information Out Of iTunes Reporter API

Overview

The iTunes Reporter interface has a lot of very useful information in it, but unfortunately Apple only provides a Java Applet to access it, and no API.

This library lets you access that data as native Python objects so that you can display, analyze, or store it however you like.

Reporter takes your API information (either username and password or AccessKey), and then lets you request information from the API. In the case of a report, it downloads the TSV (Tab Separated Values) file, unzips it, and converts it into a native Python object.

In a coming version, you will also be able to use this via the command-line.

Basic Usage

To access the iTunes Reporter API, you must first instantiate the Reporter class, using either your username and password:

from reporter import Reporter

rep = Reporter(user_id='[email protected]', password='hunter2')
print(rep.vendors)
# ['80012345', '80054321']

Or your AccessKey (obtainable via the web interface, Apple's own Reporter tool, or using the access_token property of an already instantiated Reporter object:

from reporter import Reporter

rep = Reporter(access_token='29c656f3-2dcf-1234-5678-123456789abc')
print(rep.vendors)
# ['80012345', '80054321']

In the case of using your user_id and password, at the time of your first request, Reporter will fetch your AccessKey and use it for that request and all subsequent ones.

pytunes-reporter's People

Contributors

anujism avatar chason avatar vembloud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pytunes-reporter's Issues

403 Client Error: Forbidden for url: ... in 2020.

Hello,

Trying to implement pytunes-reporter lib now in oct., 2020, I faced a problem. Right after instantiating Reporter class with my account id and access token when I make any requests I always get 403 Client Error: Forbidden for url:...

It happens even if I just request vendors:
rep = Reporter(account='123456789', access_token='xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx')
print(rep.vendors)

Account_id & access_token I use are correct (copy-paste) and it works via iTunes Reporter 2.2 well. It looks like since 2019 Apple changed something so JSON requests generated by lib do not provide a proper form. Therefore, Reporter API doesn't see my token and shows the 'Forbidden' issue. I don't have proper skills to solve this problem myself, so I need help!

Thank you!

ContentDecodingError received when trying to download amStreams file

Hi,

I am receiving a content decoding error when attempting to download amStreams summary reports. I only receive the error for this report type, all others are successful. I cannot figure out why this is happening. I also do not receive the error when using the jar as normal, only when using pytunes-reporter. Here is the error:

ContentDecodingError: ('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect header check'))

Thanks.

404 Client Error for download_sales_report-function

Hey,

since March 13th 2019 I get a 404 Client Error after invoking the download_sales_report().

This is the full error message:
Traceback (most recent call last): File "<input>", line 2, in <module> File "/Users/dembahne/anaconda3/envs/data_lake_ingestion/lib/python3.6/site-packages/reporter.py", line 156, in download_sales_report credentials)) File "/Users/dembahne/anaconda3/envs/data_lake_ingestion/lib/python3.6/site-packages/reporter.py", line 251, in _make_request response.raise_for_status() File "/Users/dembahne/anaconda3/envs/data_lake_ingestion/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://reportingitc-reporter.apple.com/reportservice/sales/v1

After some research it turned out, that the report_version-parameter of the function is no longer optional, so you have to specify a report version before fetching the data from the API. After adding report_type='1_2' (or maybe a newer version) to the function, everything worked well again.

Add a method to view token using user_id and password

Right now when you don't pass access token, it will always generate a new token even when it is not expired.
It would be good if it will first call the viewToken command to get the existing token and only generate new one if it is expired.

Make _make_request method public

Currently, _make_request method is protected. Can we change it to make_request to make it public so we can make custom requests also?

account variable not used to get reports

This is an great library. But it is not working when we have an access token which belongs to multiple accounts. Although you are taking account as parameter but not using it.

Cleaning up needed

from @georgemarshall

  • Annotating function return types would be nice
  • The mixing f strings and format makes things a bit inconsistent
  • If you are 3.5+ only, I would consider replacing requests with aiohttp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.