Getting started: Flutter Walmart add to cart
Four steps from nothing to a filled Walmart cart. You need a Walmart Affiliate API account. Questions? FAQ or contact us.
1. Create your account
Sign up with an email and password. We email you a verification link (check spam); if yours does not arrive, email helpdesk@flexxxlab.com and we will activate your account.
2. Connect your Walmart account
Register at walmart.io and request Affiliate API access. Create a key pair and upload the public key:
openssl genrsa -out walmart_private_key.pem 2048 openssl rsa -in walmart_private_key.pem -pubout -out walmart_public_key.pem
In your dashboard, paste the Consumer ID, key version and private key. CartBridge checks them with Walmart before saving. Keep the private key out of your app and out of source control.
3. Create an API key
Create a CartBridge API key on the dashboard. It is shown once. It starts with cb_.
4a. Flutter
flutter pub add cart_bridge
import 'package:cart_bridge/cart_bridge.dart';
await CartBridge(apiKey: 'YOUR_API_KEY').openCart(context, items: const [
Ingredient('chicken breast', quantity: 2, unit: 'lb'),
Ingredient('large eggs', quantity: 12, unit: 'each'),
]);
On Android, allow internet access and the https VIEW intent query in AndroidManifest.xml. Details and error handling are in the
package readme.
4b. REST
curl -X POST https://cartbridge.flexxxlab.com/v1/cart \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"store":"walmart","items":[
{"name":"chicken breast","quantity":2,"unit":"lb"},
{"name":"large eggs","quantity":12,"unit":"each"}]}'
The response has cart_url, lines, unmatched and estimated_total. Open cart_url in a WebView, a browser or the
Walmart app. Errors: 401 bad key, 403 no Walmart credentials, 400 bad request,
429 over your limit (see Retry-After). Full reference: /docs.
Limits
Free plan: 10 requests per 5 minutes and 200 requests per calendar month. See pricing.