Getting Started with Moonshine Labs API

Moonshine Labs API - Getting Started Guide

Welcome to the Moonshine Labs API Getting Started Guide! In this tutorial, we will walk you through setting up your platform, creating and managing items, generating QR codes for purchasing, and checking order statuses. By the end of this guide, you should have a basic understanding of how to use the Moonshine Labs API for Solana Play.

1. Set up your platform

To create a new Solana Play platform, you'll need to make a POST request to the /platforms endpoint. Make sure to fill in the required fields in the request body.

POST /api/solanaplay/platforms

Request body:

{
  "platformId": "your-platform-id",
  "name": "Your Platform Name",
  "url": "https://yourplatform.com",
  "twitter": "@yourplatform",
  "discordInvite": "https://discord.gg/yourplatform",
  "image": "https://yourplatform.com/logo.png",
  "description": "A short description of your platform.",
  "category": "your-category",
  "subcategory": "your-subcategory",
  "tags": ["tag1", "tag2"]
}

Check here for the response examples: [response_example_link]

You will receive a platformId, platCustPub, and platformRefId in the response. Make sure you keep them in a safe place, as you will need them later.

2. Create and manage items

Next, you'll need to create items that can be purchased on your platform. To do this, make a POST request to the /items/{platformId} endpoint with your platformId.

POST /api/solanaplay/items/{platformId}

Request body:

[
  {
    "itemId": "your-item-id",
    "label": "Your Item Name",
    "priceArray": [
      {
        "price": 1,
        "tokenName": "SOL",
        "token": "So11111111111111111111111111111111111111112",
        "active": true
      }
    ],
    "image": "https://yourplatform.com/item.png",
    "description": "A short description of your item.",
    "quantity": 1,
    "category": "your-category",
    "subcategory": "your-subcategory",
    "scenes": ["scene1", "scene2"],
    "tags": ["tag1", "tag2"],
    "requiredRoles": ["role1", "role2"],
    "excludedRoles": ["role3", "role4"]
  }
]

Check here for the response examples: [response_example_link]

You can also update and delete items using the /items/{id} endpoint with the respective HTTP methods (PUT, DELETE).

3. Generate QR codes for purchasing

To generate a QR code for purchasing an item, make a GET request to the /qr/{platformId}/{itemId}/{playerId} endpoint with your platformId, itemId, and playerId. Optionally, you can also include quantity and payToken parameters.

GET /api/solanaplay/qr/{platformId}/{itemId}/{playerId}?quantity=1&payToken=So11111111111111111111111111111111111111112

Check here for the response examples: [response_example_link]

The response will include a qrUrl, qrRefId, label, image, and link. You can display the qrUrl as a QR code on your platform, allowing users to easily purchase the item.

4. Check order status

After a user has scanned the QR code and completed the purchase, you can check the order status using the /orders/status/{id} endpoint with the qrRefId you received earlier.

GET /api/solanaplay/orders/status/{id}

Check here for the response examples: [response_example_link]

If the order is confirmed, you will receive a confirmed: true value in the response, along with a message and transaction signature.

That's it! You now have a basic understanding of how to use the Moonshine Labs API for Solana Play. For more details, please refer to the complete API documentation.