Quickstart
By the end of this page you will have listed vehicles from a showroom with their state drive-away price and hero image.
-
Get credentials. You need a
client_idandclient_secret. Dealers create them in the Vyro Dashboard under Settings > Team > (a team member) > API Clients. Partners get them from Vyro: email support@vyro.co. Start on staging.A dealer’s client reads that dealer’s showrooms. A partner reading many dealers uses an app client. See Authentication.
-
Exchange them for an access token. Tokens last 60 minutes. Cache one and reuse it until shortly before it expires.
Terminal window curl -s https://authentication-api.vyrolabs-staging.net/api-client/authenticate \-H 'Content-Type: application/json' \-d '{"client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET"}'{ "access_token": "eyJhbGciOi...", "token_type": "Bearer", "expires_in": 3600 } -
Find your showroom. Every query about stock is scoped to a showroom. Look its
idup once by code and keep it.query Showroom {showrooms(where: { code: { _eq: "your-showroom-code" } }) {idnamedomaindefault_pricing_code}} -
List vehicles. Send the query to the GraphQL endpoint with the token in the
Authorizationheader.Terminal window curl -s https://graphql.vyrolabs-staging.net/v1/graphql \-H "Authorization: Bearer $ACCESS_TOKEN" \-H 'Content-Type: application/json' \-d @- <<'JSON'{"query": "query Stock($showroomId: uuid!, $state: String!) { stocked_vehicles(where: { showroom_stocked_vehicles: { showroom_id: { _eq: $showroomId } }, is_published: { _eq: true }, is_listed: { _eq: true }, is_sold: { _eq: false }, listing_type: { _eq: retail }, pricing_codes: { _contains: [$state] } }, order_by: [{ updated_at: desc }, { id: asc }], limit: 20) { id code production_year make model badge condition odometer price: pricing_config(path: $state) assets(where: { placement: { _eq: \"featured\" } }, limit: 1) { src } } }","variables": { "showroomId": "YOUR_SHOWROOM_ID", "state": "AU_NSW" }}JSONconst query = /* GraphQL */ `query Stock($showroomId: uuid!, $state: String!) {stocked_vehicles(where: {showroom_stocked_vehicles: { showroom_id: { _eq: $showroomId } }is_published: { _eq: true }is_listed: { _eq: true }is_sold: { _eq: false }listing_type: { _eq: retail }pricing_codes: { _contains: [$state] }}order_by: [{ updated_at: desc }, { id: asc }]limit: 20) {idcodeproduction_yearmakemodelbadgeconditionodometerprice: pricing_config(path: $state)assets(where: { placement: { _eq: "featured" } }, limit: 1) {src}}}`;const res = await fetch('https://graphql.vyrolabs-staging.net/v1/graphql', {method: 'POST',headers: {Authorization: `Bearer ${accessToken}`,'Content-Type': 'application/json',},body: JSON.stringify({ query, variables: { showroomId, state: 'AU_NSW' } }),});const { data, errors } = await res.json();if (errors) throw new Error(errors[0].message);import requestsquery = """query Stock($showroomId: uuid!, $state: String!) {stocked_vehicles(where: {showroom_stocked_vehicles: { showroom_id: { _eq: $showroomId } }is_published: { _eq: true }is_listed: { _eq: true }is_sold: { _eq: false }listing_type: { _eq: retail }pricing_codes: { _contains: [$state] }}order_by: [{ updated_at: desc }, { id: asc }]limit: 20) {id code production_year make model badge condition odometerprice: pricing_config(path: $state)assets(where: { placement: { _eq: "featured" } }, limit: 1) { src }}}"""res = requests.post("https://graphql.vyrolabs-staging.net/v1/graphql",headers={"Authorization": f"Bearer {access_token}"},json={"query": query, "variables": {"showroomId": showroom_id, "state": "AU_NSW"}},timeout=30,)body = res.json()if "errors" in body:raise RuntimeError(body["errors"][0]["message"])vehicles = body["data"]["stocked_vehicles"] -
Read the result. Prices are in cents, so
4599000is $45,990.{"data": {"stocked_vehicles": [{"id": "0b6c0c1e-…","code": "2024-byd-atto-3-extended-fs003","production_year": 2024,"make": "BYD","model": "Atto 3","badge": "Extended Range","condition": "new","odometer": 0,"price": { "version": "v2", "driveAwayPrice": 4599000, "lineItems": { "…": "…" } },"assets": [{ "src": "https://ik.imagekit.io/vyro/…/hero.jpg" }]}]}}
- Build a stock feed: sync, prices, images and links for a marketplace.
- Filtering and Pagination: the two things every integration needs.
- Recipes: get-one and list queries for every common entity.