A small, complete Next.js application you can clone and point at your own Uber ad account to explore the Uber Ads API.
It implements the full OAuth 2.0 authorization code flow, wraps all 15 documented endpoints in a typed client, and ships a dashboard for browsing campaigns, ad groups, ads, stores, products, and performance reports. Types are generated from Uber's official OpenAPI specification, so the request and response shapes here are not hand-transcribed guesses.
This is example code intended for learning and local experimentation. It is not an officially supported Uber product.
- Node.js 20.9 or newer
- An app registered at developer.uber.com/dashboard with the Ads API scopes enabled
jqandcurl, only if you want to runscripts/uber-ads-api.sh
git clone https://github.com/ekim197/uber-ads-api-example
cd uber-ads-api-example
npm install
cp .env.example .env.localOpen .env.local and fill in the two required values:
UBER_CLIENT_ID=your_client_id
UBER_CLIENT_SECRET=your_client_secretRegister http://localhost:3000/auth/callback as a redirect URI on your Uber
app — it must match exactly, including the scheme and port. Then:
npm run devIf you fork this repository, keep these in place:
- Never commit
.env.local. Only.env.exampleis tracked, and it contains no values. - Keep
UBER_CLIENT_SECRETserver-side. Any variable prefixed withNEXT_PUBLIC_is inlined into the browser bundle, which is why the secret deliberately has no such prefix. - Tokens are stored in
httpOnlycookies and attached by the server-side proxy, so they never reach client JavaScript. - The OAuth
stateparameter is generated, stored in anhttpOnlycookie, and verified on the callback. A mismatch aborts the login. - The proxy restricts forwarding to
/v1/ads/*so a session token cannot be used against unrelated Uber APIs. - Cookies are marked
secureautomatically whenNODE_ENV=production.
Apache-2.0 — see LICENSE.