GrabFood Partner API Python SDK
Official Python SDK for the GrabFood Partner API — enables food delivery merchants and platform partners in Southeast Asia to manage orders, store hours, menus, and campaigns programmatically. Auto-generated from Grab's OpenAPI spec using OpenAPITools PythonClientCodegen. IMPORTANT: This SDK covers GrabFood only (merchant/food delivery). Grab rides/mobility has no official Python SDK. The SDK is not published on PyPI — install via GitHub only.
Warnings
- breaking GrabFood Partner API access requires a signed partnership agreement with Grab. It is not self-serve — you must apply via the Grab Developer Portal and be approved as a merchant or technology partner. Without approval, API credentials are not issued.
- gotcha 'grab' on PyPI is a completely unrelated Python web scraping framework (github.com/lorien/grab). pip install grab installs the wrong package. The GrabFood SDK is not on PyPI at all.
- gotcha The SDK default host is STG_ENV (sandbox/staging). Forgetting to switch to PRD_ENV means all production calls hit the sandbox silently — no error is thrown.
- gotcha OAuth tokens are not auto-refreshed. The SDK returns expires_in in the token response but does not implement token refresh logic. In long-running services, tokens expire and API calls begin returning 401 errors.
- gotcha This SDK covers GrabFood (food delivery merchant API) only. There is no official Python SDK for Grab rides, GrabPay, or GrabExpress. Attempting to call non-GrabFood endpoints with this SDK will fail.
- gotcha SDK is auto-generated from OpenAPI spec (PythonClientCodegen). The SDK is geographically scoped — GrabFood operates in Singapore, Malaysia, Indonesia, Thailand, Vietnam, Philippines, Cambodia, and Myanmar. Merchant IDs and API behavior may vary by country.
Install
-
pip install git+https://github.com/grab/grabfood-api-sdk-python.git
Imports
- grabfood
import grabfood
Quickstart
import grabfood
from grabfood.configs.config import STG_ENV, PRD_ENV, STG_AUTH_ENV, PRD_AUTH_ENV
from grabfood.rest import ApiException
# Step 1: Get OAuth token (client credentials flow)
# Credentials obtained from Grab Developer Portal
CLIENT_ID = 'your_client_id'
CLIENT_SECRET = 'your_client_secret'
# Auth configuration — use STG_AUTH_ENV for staging, PRD_AUTH_ENV for production
auth_config = grabfood.Configuration(host=STG_AUTH_ENV)
with grabfood.ApiClient(auth_config) as auth_client:
auth_api = grabfood.GetOauthGrabApi(auth_client)
oauth_request = grabfood.GrabOauthRequest(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
grant_type='client_credentials',
scope='food.partner_api'
)
token_response = auth_api.get_oauth_grab('application/json', oauth_request)
ACCESS_TOKEN = 'Bearer ' + token_response.access_token
# Store token_response.expires_in to know when to refresh
# Step 2: Use token against GrabFood API
# IMPORTANT: Default host is STG_ENV (sandbox). Switch to PRD_ENV for production.
configuration = grabfood.Configuration(host=PRD_ENV) # or STG_ENV for testing
MERCHANT_ID = 'your_merchant_id'
with grabfood.ApiClient(configuration) as api_client:
# Get store hours
store_api = grabfood.GetStoreHourApi(api_client)
try:
response = store_api.get_store_hour(
authorization=ACCESS_TOKEN,
merchant_id=MERCHANT_ID
)
print(response)
except ApiException as e:
print(f'API error: {e}')
# Accept an order
order_api = grabfood.AcceptRejectOrderApi(api_client)
try:
order_api.accept_reject_order(
authorization=ACCESS_TOKEN,
content_type='application/json',
accept_order_request=grabfood.AcceptOrderRequest()
)
except ApiException as e:
print(f'Order error: {e}')