-
API version: 1.1.3
-
Generator version: 7.8.0
For more information, please visit https://developer.grab.com
Automatically generated by the OpenAPI Generator
Building the API client library requires:
- Java 1.8+
- Maven/Gradle
To install the API client library to your local Maven repository, simply execute:
mvn clean install
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
mvn clean deploy
Refer to the OSSRH Guide for more information.
Add this dependency to your project's POM:
<dependency>
<groupId>com.grab</groupId>
<artifactId>grabfood-api-sdk-java</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
Add this dependency to your project's build file:
repositories {
mavenCentral() // Needed if the 'grabfood-api-sdk-java' jar has been published to maven central.
mavenLocal() // Needed if the 'grabfood-api-sdk-java' jar has been published to the local maven repo.
}
dependencies {
implementation "com.grab:grabfood-api-sdk-java:1.0.0"
}
At first generate the JAR by executing:
mvn clean package
Then manually install the following JARs:
target/grabfood-api-sdk-java-1.0.0.jar
target/lib/*.jar
Please follow the installation instruction and execute the following Java code:
In the example below, we start by acquiring an OAuth2 access token. In your applications, it's important to handle OAuth2 tokens efficiently. This means:
- Store the received access token once it's obtained.
- Use this stored access token for as long as it's valid.
- Only request a new access token when the current one has expired.
By following these practices, you minimize the number of requests to the server, making your application more efficient and responsive.
You can usually determine the validity of a token by the expires_in
attribute in the OAuth2 token response.
import com.grab.grabfood.client.ApiClient;
import com.grab.grabfood.client.ApiException;
import com.grab.grabfood.client.Configuration;
import com.grab.grabfood.client.model.*;
import com.grab.grabfood.client.api.*;
public class Example {
public static void main(String[] args) {
ApiClient client = Configuration.getDefaultApiClient();
client.setServerIndex(Configuration.StgEnv);
GetOauthGrabApi authInstance = new GetOauthGrabApi(client);
authInstance.setHostIndex(client.getServerIndex());
String contentType = "application/json";
GrabOauthRequest req = new GrabOauthRequest();
req.setClientId("client_id");
req.setClientSecret("client_secret");
req.setGrantType("client_credentials");
req.setScope("food.partner_api");
try {
GrabOauthResponse authResp = authInstance.getOauthGrab(contentType, req);
// Request a new token only when the previous one has expired.
// Can utilize the `expires_in` from authResp.getExpiresIn() to determine the validity of the token.
ACCESS_TOKEN = authResp.getAccessToken();
} catch (ApiException e) {
System.err.println("Exception when calling GetOauthGrabApi#getOauthGrab");
e.printStackTrace();
}
GetStoreHourApi apiInstance = new GetStoreHourApi(client);
String authorization = "Bearer " + ACCESS_TOKEN;
String merchantID = "1-CYNGRUNGSBCCC";
try {
StoreHourResponse result = apiInstance.getStoreHour(authorization, merchantID);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling GetStoreHourApi#getStoreHour");
e.printStackTrace();
}
}
}
For handling webhook requests, we provide dedicated models for both requests and responses. Please refer to the list of available models provided below for more details.
The base URL for OAuth2 URIs is https://api.grab.com
For other GrabFood partner API endpoints, URIs are relative to https://partner-api.grab.com/grabfood
Class | Method | HTTP request | Description |
---|---|---|---|
AcceptRejectOrderApi | acceptRejectOrder | POST /partner/v1/order/prepare | Manually accept/reject orders |
CancelOrderApi | cancelOrder | PUT /partner/v1/order/cancel | Cancel an order |
CheckOrderCancelableApi | checkOrderCancelable | GET /partner/v1/order/cancelable | Check order cancelable |
CreateCampaignApi | createCampaign | POST /partner/v1/campaigns | Create campaign |
DeleteCampaignApi | deleteCampaign | DELETE /partner/v1/campaigns/{campaign_id} | Delete campaigns |
EditOrderApi | editOrder | PUT /partner/v1/orders/{orderID} | Edit Order |
GetDineinVoucherApi | getDineinVoucher | GET /partner/v1/dinein/voucher | Get Dine In Voucher |
GetOauthGrabApi | getOauthGrab | POST /grabid/v1/oauth2/token | Get Oauth access token |
GetStoreHourApi | getStoreHour | GET /partner/v2/merchants/{merchantID}/store/hours | Get Store Hours |
GetStoreStatusApi | getStoreStatus | GET /partner/v1/merchants/{merchantID}/store/status | Get Store Status |
ListCampaignApi | listCampaign | GET /partner/v1/campaigns | List campaigns |
ListOrdersApi | listOrders | GET /partner/v1/orders | List orders |
MarkOrderReadyApi | markOrderReady | POST /partner/v1/orders/mark | Mark order as ready |
NotifyMembershipWebviewApi | notifyMembershipWebview | POST /partner/v1/membership/notify | Notify Membership |
PauseStoreApi | pauseStore | PUT /partner/v1/merchant/pause | Pause store |
RedeemDineinVoucherApi | redeemDineinVoucher | POST /partner/v1/dinein/voucher/redeem | Redeem Dine In Voucher |
TraceMenuSyncApi | traceMenuSync | GET /partner/v1/merchant/menu/trace | Trace menu sync |
UpdateCampaignApi | updateCampaign | PUT /partner/v1/campaigns/{campaign_id} | Update campaign |
UpdateDeliveryStateApi | updateDeliveryState | POST /partner/v1/order/delivery | Update delivery state |
UpdateMenuNotificationApi | updateMenuNotification | POST /partner/v1/merchant/menu/notification | Notify Grab of updated menu |
UpdateMenuRecordApi | batchUpdateMenu | PUT /partner/v1/batch/menu | Batch Update Menu |
UpdateMenuRecordApi | updateMenu | PUT /partner/v1/menu | Update menu record |
UpdateOrderReadyTimeApi | updateOrderReadyTime | PUT /partner/v1/order/readytime | Update new order ready time |
UpdateStoreDeliveryHourApi | updateStoreDeliveryHour | PUT /partner/v1/merchants/{merchantID}/store/opening-hours | Update Store Delivery Hours |
UpdateStoreDineInHourApi | updateStoreDineInHour | PUT /partner/v1/merchants/{merchantID}/store/dine-in-hours | Update Store Dine-in Hours |
UpdateStoreSpecialHourApi | updateStoreSpecialHour | PUT /partner/v2/merchants/{merchantID}/store/special-opening-hour | Update Store Special Hours |
- AcceptOrderRequest
- Address
- AdvancedPricing
- BatchUpdateMenuItem
- BatchUpdateMenuResponse
- BindMembershipNativeRequest
- BindMembershipNativeResponse
- Campaign
- CampaignConditions
- CampaignDiscount
- CampaignQuotas
- CampaignScope
- CancelCode
- CancelOrderLimitType
- CancelOrderRequest
- CancelOrderResponse
- CancelReason
- CheckOrderCancelableResponse
- Coordinates
- CreateCampaignRequest
- CreateCampaignResponse
- Currency
- DineIn
- EditOrderItem
- EditOrderRequest
- Error
- GetDineInVoucherResponse
- GetMembershipNativeResponse
- GetMembershipNativeResponsePointInfo
- GetMembershipRequest
- GetMembershipWebviewResponse
- GetMenuNewResponse
- GetMenuOldResponse
- GetRewardNativeRequest
- GetRewardNativeResponse
- GrabOauthRequest
- GrabOauthResponse
- ListCampaignResponse
- ListOrdersResponse
- MarkOrderRequest
- MenuCategory
- MenuEntity
- MenuEntityError
- MenuItem
- MenuModifier
- MenuSection
- MenuSectionCategory
- MenuSectionCategoryItem
- MenuSyncFail
- MenuSyncFailCategory
- MenuSyncFailItem
- MenuSyncFailModifier
- MenuSyncFailModifierGroup
- MenuSyncFailServiceHours
- MenuSyncResponse
- MenuSyncWebhookRequest
- ModifierGroup
- NewOrderTimeRequest
- NotifyMembershipWebviewRequest
- OpenPeriod
- Order
- OrderCampaign
- OrderDeliveryRequest
- OrderFeatureFlags
- OrderFreeItem
- OrderItem
- OrderItemModifier
- OrderPrice
- OrderPromo
- OrderReadyEstimation
- OrderStateRequest
- OutOfStockInstruction
- PartnerOauthRequest
- PartnerOauthResponse
- PauseStoreRequest
- Purchasability
- Receiver
- RedeemDineInVoucherRequest
- RedeemDineInVoucherResponse
- RedeemResult
- RegisterMembershipNativeRequest
- RegisterMembershipNativeResponse
- RewardItem
- SellingTime
- ServiceHour
- ServiceHours
- SpecialOpeningHour
- SpecialOpeningHourMetadata
- SpecialOpeningHourOpeningHours
- StoreHour
- StoreHourResponse
- StoreStatusResponse
- SubmitOrderRequest
- UnbindMembershipNativeRequest
- UnlinkMembershipWebviewRequest
- UpdateAdvancedPricing
- UpdateCampaignRequest
- UpdateDeliveryHourRequest
- UpdateDeliveryHourResponse
- UpdateDineInHourRequest
- UpdateDineInHourResponse
- UpdateMenuItem
- UpdateMenuModifier
- UpdateMenuNotifRequest
- UpdateMenuRequest
- UpdatePurchasability
- UpdateSpecialHourRequest
- UpdateSpecialHourResponse
- Voucher
- VoucherDescriptionInfo
- WorkingHour
- WorkingHourDay
It's recommended to create an instance of ApiClient
per thread in a multithreaded environment to avoid any potential issues.