From 6d8efb8c91e3ef4066350ccb22ba7b2f4a78cf0b Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 21:29:40 +0000 Subject: [PATCH 1/4] feat: Updated package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 91fa839..57aa6d1 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "google-play-scraper": "^10.0.0", "npm-check-updates": "^16.14.4", "postman-to-openapi": "^3.0.1", - "swagger-ui-express": "^5.0.0" + "swagger-ui-express": "^5.0.0", + "openapi-to-graphql": "^2.2.2" }, "devDependencies": { "eslint": "^8.49.0", From 508ac9a36536498a5ea77ae15746fb04329b3706 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 21:33:56 +0000 Subject: [PATCH 2/4] feat: Add GraphQL endpoint using openapi-to-graphq --- lib/graphql.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lib/graphql.js diff --git a/lib/graphql.js b/lib/graphql.js new file mode 100644 index 0000000..6b1ca1b --- /dev/null +++ b/lib/graphql.js @@ -0,0 +1,20 @@ +import express from 'express'; +import { graphqlHTTP } from 'express-graphql'; +import { createGraphQLSchema } from 'openapi-to-graphql'; +import path from 'path'; +import fs from 'fs'; + +// Load the OpenAPI specification +const openApiSpec = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../openapi/swagger.json'), 'utf8')); + +// Generate the GraphQL schema from the OpenAPI specification +const { schema } = createGraphQLSchema(openApiSpec); + +// Create a new GraphQL server +const graphqlServer = express(); +graphqlServer.use('/graphql', graphqlHTTP({ + schema: schema, + graphiql: true, +})); + +export default graphqlServer; From 9abbec79bfe24a00fa01a4828259cb00de37e2e0 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 21:38:38 +0000 Subject: [PATCH 3/4] feat: Updated lib/index.js --- lib/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/index.js b/lib/index.js index bc86bcc..627ac59 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,6 +4,7 @@ import Express from 'express'; import gplay from 'google-play-scraper'; import path from 'path'; import qs from 'querystring'; +import graphqlServer from './graphql'; const router = Express.Router(); @@ -249,4 +250,7 @@ function errorHandler(err, req, res, next) { router.use(errorHandler); +// Use the GraphQL server as middleware +router.use('/graphql', graphqlServer); + export default router; From 480b184b89565580296a963f1a143eb7196590f4 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 21:39:37 +0000 Subject: [PATCH 4/4] feat: Updated README.md --- README.md | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b3a7457..a20d0bc 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,49 @@ # Google Play API + ![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/srikanthlogic/google-play-api?include_prereleases&label=version) [![Newman Run](https://github.com/srikanthlogic/google-play-api/actions/workflows/newman.yml/badge.svg)](https://github.com/srikanthlogic/google-play-api/actions/workflows/newman.yml) [![API Documentation](https://img.shields.io/badge/api-documentation-brightgreen)](https://gplayapi.cashlessconsumer.in/) [![Deploy](https://button.deta.dev/1/svg)](https://deta.space/discovery/@cashlessconsumer/googleplayapi) Google Play API is a REST API wrapper originally built on top of [google-play-scraper](https://github.com/facundoolano/google-play-scraper) by [Facundoolano](https://github.com/facundoolano) to fetch metadata from [Google Play](https://en.wikipedia.org/wiki/Google_Play). This repository extends it and adds additional endpoints. ## API Server + The API Server is built on ExpressJS and self contains API documentation. To run locally: -* Clone the repository and run -* `npm install` -* `npm run generateoas` - Generates the OpenAPI specification -* `npm start` + +- Clone the repository and run +- `npm install` +- `npm run generateoas` - Generates the OpenAPI specification +- `npm start` ### Deployments + The API Server can be installed as a [Deta app](https://deta.space/discovery/@cashlessconsumer/googleplayapi). ### Roadmap -* [ ] Expose more endpoints helping towards archiving. -* [ ] Support Global options -* [X] Deta Support. [#34](https://github.com/srikanthlogic/google-play-api/issues/34) -* [X] Support Lists [#36](https://github.com/srikanthlogic/google-play-api/issues/36) -* [X] Support privacy friendly reviews extraction [#40](https://github.com/srikanthlogic/google-play-api/issues/40) + +- [ ] Expose more endpoints helping towards archiving. +- [ ] Support Global options +- [x] Deta Support. [#34](https://github.com/srikanthlogic/google-play-api/issues/34) +- [x] Support Lists [#36](https://github.com/srikanthlogic/google-play-api/issues/36) +- [x] Support privacy friendly reviews extraction [#40](https://github.com/srikanthlogic/google-play-api/issues/40) +- [x] Support GraphQL endpoint. [#45](https://github.com/srikanthlogic/google-play-api/issues/45) + +### GraphQL Endpoint + +The API now supports a GraphQL endpoint at `/graphql`. This endpoint allows for more flexible queries than the REST API. + +To query the GraphQL endpoint, send a POST request with a JSON body containing your GraphQL query. For example: + +```json +{ + "query": "{ app(id: \"com.example.app\") { title, developer } }" +} +``` + +This will return the title and developer of the app with the id "com.example.app". + +The data available for querying includes all the data available through the REST API, such as app details, reviews, and similar apps. ## Disclaimer -* Google Play data is bound by terms of Google. We believe - the data in the Play Store ecosystem, belong to people (Users) and hence must be available to them in form that will allow them to make best use of. + +- Google Play data is bound by terms of Google. We believe - the data in the Play Store ecosystem, belong to people (Users) and hence must be available to them in form that will allow them to make best use of.