Giter Club home page Giter Club logo

node-appstore-connect's Introduction

npm

@egodigital/appstore-connect

A simplfied library for Node.js 10+ for accessing Apple's App Store Connect API, written in TypeScript.

The module is quite new, so issues and pull requests are very welcome :-)

Install

Execute the following command from your project folder, where your package.json file is stored:

npm install --save @egodigital/appstore-connect

Usage

import * as fs from 'fs';
import { Client as AppStoreConnectClient, DownloadSalesReportFrequency } from '@egodigital/appstore-connect';

const PRIVATE_KEY = fs.readFileSync(
    '/path/to/your/p8/file'  // downloaded from https://appstoreconnect.apple.com/access/api
);

const CLIENT = new AppStoreConnectClient({
    apiKey: '<YOUR-API-KEY>',  // s. https://appstoreconnect.apple.com/access/api
    issuerId: '<YOUR-ISSUER-ID>',  // s. https://appstoreconnect.apple.com/access/api
    privateKey: PRIVATE_KEY,
});

const SUMMARY = await CLIENT.getAppDownloads({
    frequency: DownloadSalesReportFrequency.Weekly,
    vendorId: '<YOUR-VENDOR-ID>',  // s. https://appstoreconnect.apple.com/itc/payments_and_financial_reports
});

console.log(
    SUMMARY
);

Documentation

The API documentation can be found here.

node-appstore-connect's People

Stargazers

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

Watchers

 avatar  avatar  avatar

node-appstore-connect's Issues

App Store Connect refuses requests built with searchParams

I seem to be the only one with that issue but constructing the URL with the searchParams left me with App Store Connect telling me it's a bad request.

My ugly fix is to template the URL like that https://api.appstoreconnect.apple.com/v1/salesReports?filter[frequency]=${frequency}&filter[reportDate]=${filterReportDate}&filter[reportSubType]=SUMMARY&filter[reportType]=SALES&filter[vendorNumber]=${opts.vendorId}&filter[version]=1_0 without the need for search params.

Since there are no other issues like this I suppose I'm at fault somewhere but if it helps feel free to check out https://github.com/Reiszecke/node-appstore-connect/blob/master/src/index.ts#L262

There is some typescript issue with this module

Hello, now I have some problem with appstore-connect. So, I want to use your library but, there is some typescript issue.

$ tsc
##[error]node_modules/@egodigital/appstore-connect/lib/index.d.ts(17,23): error TS4090: Conflicting definitions for 'node' found at '/home/ubuntu/var/www/production/source/node_modules/@egodigital/appstore-connect/node_modules/@types/node/ts3.2/index.d.ts' and '/home/ubuntu/var/www/production/source/node_modules/@types/node/ts3.2/index.d.ts'. Consider installing a specific version of this library to resolve the conflict.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I think index.d.ts is wrong, cuz error occur in <reference type="node">.

Thank you so much for your effort.

Got 401 error while requesting App Store Connect API

Double checked private key, API key, and issuer ID. Got the following error while calling App Store Connect API.

Error: Unexpected Response: [401] '{
        "errors": [{
                "status": "401",
                "code": "NOT_AUTHORIZED",
                "title": "Authentication credentials are missing or invalid.",
                "detail": "Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens"
        }]
}'
at Client.downloadSalesReportSummary (.../node_modules/@egodigital/appstore-connect/lib/index.js:137:19)
...

Googled around and got it to work. Not sure it's an issue of Apple or this library.

Appreciate any help or advice.

Error: error:0909006C:PEM routines:get_name:no start line

const ret = this[kHandle].sign(data, format, type, passphrase, rsaPadding,
^

Error: error:0909006C:PEM routines:get_name:no start line
at Sign.sign (internal/crypto/sig.js:110:29)
at sign (D:\repo\jenkins-shared-library_jenkins\web\app-store\node_modules\jwa\index.js:152:45)
at Object.sign (D:\repo\jenkins-shared-library_jenkins\web\app-store\node_modules\jwa\index.js:200:27)
at Object.jwsSign [as sign] (D:\repo\jenkins-shared-library_jenkins\web\app-store\node_modules\jws\lib\sign-stream.js:32:24)
at Object.module.exports [as sign] (D:\repo\jenkins-shared-library_jenkins\web\app-store\node_modules\jsonwebtoken\sign.js:204:16)
at Object. (D:\repo\jenkins-shared-library_jenkins\web\app-store\app-store-connect-api.js:34:25)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14) {
library: 'PEM routines',
function: 'get_name',
reason: 'no start line',
code: 'ERR_OSSL_PEM_NO_START_LINE'
}

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.