{"id":29009681,"url":"https://github.com/grab/grabfood-api-sdk-node","last_synced_at":"2025-06-25T15:12:08.933Z","repository":{"id":277981396,"uuid":"920364119","full_name":"grab/grabfood-api-sdk-node","owner":"grab","description":"grabfood api sdk node","archived":false,"fork":false,"pushed_at":"2025-03-12T06:48:45.000Z","size":80,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-12T07:28:59.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-22T02:42:21.000Z","updated_at":"2025-03-12T06:41:13.000Z","dependencies_parsed_at":"2025-02-17T11:25:50.692Z","dependency_job_id":"60ba62a7-7e0d-4453-a792-e45c9edfa0f7","html_url":"https://github.com/grab/grabfood-api-sdk-node","commit_stats":null,"previous_names":["grab/grabfood-api-sdk-node"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/grab/grabfood-api-sdk-node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grab%2Fgrabfood-api-sdk-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grab%2Fgrabfood-api-sdk-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grab%2Fgrabfood-api-sdk-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grab%2Fgrabfood-api-sdk-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grab","download_url":"https://codeload.github.com/grab/grabfood-api-sdk-node/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grab%2Fgrabfood-api-sdk-node/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261897065,"owners_count":23226653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-25T15:12:08.330Z","updated_at":"2025-06-25T15:12:08.918Z","avatar_url":"https://github.com/grab.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeScript Node API client for GrabFood\n\n## Overview\n\nThis API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.\n\n- App version: 1.1.3\n- Package version: 1.0.2\n- Generator version: 7.8.0\n\nFor more information, please visit https://developer.grab.com\n\n## Installation\n\n```shell\nnpm install https://github.com/grab/grabfood-api-sdk-node\n```\n\n## Usage Example\n\nIn the example below, we start by acquiring an OAuth2 access token. In your applications, it's important to handle OAuth2 tokens efficiently. This means:\n\n- Store the received access token once it's obtained.\n- Use this stored access token for as long as it's valid.\n- Only request a new access token when the current one has expired.\n\nBy following these practices, you minimize the number of requests to the server, making your application more efficient and responsive.\n\nYou can usually determine the validity of a token by the `expires_in` attribute in the OAuth2 token response.\n\nBelow is an example of how to obtain an access token using the `GetOauthGrabApi` class. This class is generated from the `getOauthGrab` operation in the `GetOauthGrabApiService` service. Do note that you only have to run this function once to obtain the access token. Only run it again when the token has expired.\n\n```typescript\nimport { GetOauthGrabApi, GrabOauthRequest, StgAuthEnv } from \"@grab/grabfood-api-sdk/api\";\n\nasync function getAccessToken(): Promise\u003cstring | undefined\u003e {\n  const api = new GetOauthGrabApi(StgAuthEnv);\n  const request: GrabOauthRequest = {\n    client_id: \"YOUR_CLIENT_ID\",\n    client_secret: \"YOUR_CLIENT_SECRET\",\n    grant_type: \"client_credentials\",\n    scope: \"food.partner_api\",\n  };\n\n  try {\n    const response = await api.getOauthGrab(\"application/json\", request);\n    return \"Bearer \" + response.body.access_token;\n  } catch (error) {\n    console.error(\"Error: \", (error as any)?.body ?? error);\n    throw error;\n  }\n}\n```\n\nAfter obtaining the access token, you can use it to make requests to the GrabFood API. Below is an example of how to use the `CreateCampaignApi` class to create a merchant campaign.\n\n```typescript\nimport {\n  StgEnv,\n  CreateCampaignApi,\n  CreateCampaignRequest,\n  CampaignConditions,\n  CampaignDiscount,\n  CampaignScope,\n} from \"@grab/grabfood-api-sdk/api\";\n\nasync function CreateCampaign(): Promise\u003cvoid\u003e {\n  const api = new CreateCampaignApi(StgEnv);\n\n  const contentType = \"application/json\";\n  const authorization = \"Your-Access-Token (Eg:Bearer \u003cToken\u003e)\";\n  const createCampaignRequest: CreateCampaignRequest = {\n    merchantID: \"1-CYNGRUNGSBCCC\",\n    name: \"Diskaun 15% dengan pesanan minimum RM1.00\",\n    quotas: { totalCount: 999, totalCountPerUser: 1 },\n    conditions: {\n      startTime: new Date(\"2025-01-15T06:00:00.000Z\"),\n      endTime: new Date(\"2025-01-16T09:00:00.000Z\"),\n      eaterType: CampaignConditions.EaterTypeEnum.All,\n      minBasketAmount: 1,\n      bundleQuantity: 0,\n      workingHour: {\n        sun: { periods: [{ startTime: \"00:00\", endTime: \"23:59\" }] },\n        mon: { periods: [{ startTime: \"00:00\", endTime: \"23:59\" }] },\n        tue: { periods: [{ startTime: \"00:00\", endTime: \"23:59\" }] },\n        wed: { periods: [{ startTime: \"00:00\", endTime: \"23:59\" }] },\n        thu: { periods: [{ startTime: \"00:00\", endTime: \"23:59\" }] },\n        fri: { periods: [{ startTime: \"00:00\", endTime: \"23:59\" }] },\n        sat: { periods: [{ startTime: \"00:00\", endTime: \"23:59\" }] },\n      },\n    },\n    discount: {\n      type: CampaignDiscount.TypeEnum.Percentage,\n      cap: 0,\n      value: 15,\n      scope: { type: CampaignScope.TypeEnum.Order, objectIDs: [] },\n    },\n    customTag: \"\",\n  };\n\n  try {\n    const result = await api.createCampaign(contentType, authorization, createCampaignRequest);\n    console.log(\"Result: \", JSON.stringify(result.body, null, 2));\n  } catch (error) {\n    console.error(\"Error: \", (error as any)?.body ?? error);\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrab%2Fgrabfood-api-sdk-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrab%2Fgrabfood-api-sdk-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrab%2Fgrabfood-api-sdk-node/lists"}