> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crossmint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Literature Quickstart ⚡

> Register your literature works on Story in under 5 minutes

In this quickstart, you will:

* Register a book series as an IP collection
* Register a book as an IP asset

<Note> This quickstart is under development as new features are added to the Story Protocol daily. </Note>

## Preparation Steps

<Steps>
  <Step title="Create a Developer Account and Project">
    <Snippet file="create-developer-account.mdx" />
  </Step>

  <Step title="Get an API Key">
    Create a server-side API key with these scopes:
    `collection.create`,
    `collection.update`,
    `collection.read`,
    `nfts.create`,
    `nfts.read`.

    This allows your API key to perform any kind of asset registration action.
  </Step>
</Steps>

## Register a Book Series

<Steps>
  <Step title="Create an IP Collection">
    This quickstart will register the Harry Potter book series as an IP collection.

    <CodeGroup>
      ```typescript createCollection.ts theme={null}
      const response = await fetch("https://staging.crossmint.com/api/v1/ip/collections", {
          method: "POST",
          headers: {
              "X-API-KEY": "<YOUR_API_KEY>",
              "Content-Type": "application/json"
          },
          body: JSON.stringify({
              metadata: {
                  description: "The collection of Harry Potter books",
                  name: "Harry Potter Series",
                  symbol: "HP"
              },
              chain: "story-testnet"
          })
      });

      const collection = await response.json();
      console.log("Collection created:", collection);
      ```

      ```typescript response theme={null}
      {
          id: '1ffb0fc3-b652-4a0e-b748-3e09c3608826',
          actionId: '1ffb0fc3-b652-4a0e-b748-3e09c3608826',
          metadata: {
              name: 'Harry Potter Series',
              symbol: 'HP',
              description: 'The collection of Harry Potter books'
          },
          onChain: { chain: 'story-testnet' }
      }
      ```
    </CodeGroup>

    Customize the collection's metadata according to your needs and run the script:

    <CodeGroup>
      ```bash TypeScript theme={null}
      npx tsx createCollection.ts
      ```
    </CodeGroup>
  </Step>
</Steps>

## Register a Book

<Steps>
  <Step title="Register an IP Asset">
    Every written work may have different contributors and metadata. When defining an IP asset you can:

    * Specify multiple contributors (like authors, illustrators, and publishers) with their respective revenue shares
    * Attach relevant media files
    * Include important metadata like creation dates and identifiers

    <CodeGroup>
      ```typescript registerIPAsset.ts theme={null}
      const response = await fetch("https://staging.crossmint.com/api/v1/ip/collections/{collectionId}/ipassets", {
          method: "POST",
          headers: {
              "X-API-KEY": "<YOUR_API_KEY>",
              "Content-Type": "application/json"
          },
          body: JSON.stringify({
              owner: 'email:creator@example.com:story-testnet',
              nftMetadata: {
                  name: 'Art #123',
                  description: 'A unique story NFT',
                  image: 'https://example.com/nft/123.png'
              },
              ipAssetMetadata: {
                  title: 'Harry Potter and the Philosopher\'s Stone',
                  createdAt: '1997-06-26T00:00:00',
                  ipType: 'literature',
                  image: 'link_to_epub',
                  imageHash: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
                  mediaUrl: 'link_to_epub',
                  mediaHash: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
                  mediaType: 'application/epub+zip',
                  creators: [
                      {
                          name: 'JK Rowling',
                          email: 'JKRowling@example.com',
                          address: '0x123',
                          description: 'Author',
                          contributionPercent: 80,
                          socialMedia: [
                              {
                                  platform: 'Wikipedia',
                                  url: 'https://en.wikipedia.org/wiki/J._K._Rowling'
                              }
                          ]
                      },
                      {
                          name: 'Thomas Taylor',
                          email: 'ThomasTaylor@example.com',
                          crossmintUserLocator: 'email:ThomasTaylor@example.com:story-testnet',
                          description: 'Illustrator',
                          contributionPercent: 15
                      },
                      {
                          name: 'Bloomsbury Publishing',
                          email: 'BloomsburyPublishing@example.com',
                          address: '0x123',
                          description: 'Publisher',
                          contributionPercent: 5,
                          socialMedia: [
                              {
                                  platform: 'Website',
                                  url: 'https://www.bloomsbury.com/'
                              }
                          ]
                      }
                  ],
                  media: [
                      {
                          name: 'ePub',
                          url: 'link_to_epub',
                          mimeType: 'application/epub+zip'
                      },
                      {
                          name: 'Book Summary PDF',
                          url: 'link_to_book_summary_pdf',
                          mimeType: 'application/pdf'
                      }
                  ],
                  attributes: [
                      {
                          key: 'ISBN',
                          value: '978-0-7475-3269-0'
                      },
                      {
                          key: 'Genre',
                          value: 'Fantasy'
                      }
                  ]
              }
          })
      });

      const ipAsset = await response.json();
      console.log("IP Asset:", ipAsset);
      ```

      ```typescript response theme={null}
      {
          "id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
          "actionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
          "nftMetadata": {
              "name": "Art #123",
              "description": "A unique story NFT",
              "image": "https://example.com/nft/123.png"
          },
          "ipAssetMetadata": {
              "title": "Harry Potter and the Philosopher's Stone",
              "createdAt": "1997-06-26T00:00:00",
              "ipType": "literature",
              "creators": [
              {
                  "name": "JK Rowling",
                  "email": "email:JKRowling@example.com",
                  "description": "Author",
                  "contributionPercent": 80,
                  "socialMedia": [
                  {
                      "platform": "Wikipedia",
                      "url": "https://en.wikipedia.org/wiki/J._K._Rowling"
                  }
                  ]
              },
              {
                  "name": "Thomas Taylor",
                  "email": "email:ThomasTaylor@example.com",
                  "description": "Illustrator",
                  "contributionPercent": 15
              },
              {
                  "name": "Bloomsbury Publishing",
                  "email": "email:BloomsburyPublishing@example.com",
                  "description": "Publisher",
                  "contributionPercent": 5,
                  "socialMedia": [
                  {
                      "platform": "Website",
                      "url": "https://www.bloomsbury.com/"
                  }
                  ]
              }
              ],
              "media": [
              {
                  "name": "ePub",
                  "url": "link_to_epub",
                  "mimeType": "application/epub+zip"
              },
              {
                  "name": "Book Summary PDF",
                  "url": "link_to_book_summary_pdf",
                  "mimeType": "application/pdf"
              }
              ],
              "attributes": [
              {
                  "key": "ISBN",
                  "value": "978-0-7475-3269-0"
              },
              {
                  "key": "Genre",
                  "value": "Fantasy"
              }
              ]
          },
          "onChain": {
              "status": "success",
              "chain": "story-testnet",
              "contractAddress": "0x123",
              "ipAssetId": "0xAC6062FF53fa41e61Fe01B89B83d9dB96b5F9280",
              "tokenId": "1",
              "txId": "0x123",
              "explorerLink": "https://explorer.story.foundation/ipa/0xAC6062FF53fa41e61Fe01B89B83d9dB96b5F9280"
          }
      }
      ```
    </CodeGroup>

    Now, run the script:

    <CodeGroup>
      ```bash TypeScript theme={null}
      npx tsx registerIPAsset.ts
      ```
    </CodeGroup>
  </Step>
</Steps>

## Retrieve Your IP Asset

<Steps>
  <Step title="Get IP Asset Details">
    After registering your IP asset, you can retrieve its details to verify the information or display it in your application.

    <CodeGroup>
      ```typescript getIPAsset.ts theme={null}
      const response = await fetch("https://staging.crossmint.com/api/v1/ip/collections/{collectionId}/ipassets/{ipAssetId}", {
          method: "GET",
          headers: {
              "X-API-KEY": "<YOUR_API_KEY>",
              "Content-Type": "application/json"
          }
      });

      const ipAsset = await response.json();
      console.log("IP Asset:", ipAsset);
      ```

      ```typescript response theme={null}
      {
          "id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
          "nftMetadata": {
              "name": "Art #123",
              "description": "A unique story NFT",
              "image": "https://example.com/nft/123.png"
          },
          "ipAssetMetadata": {
              "title": "Harry Potter and the Philosopher's Stone",
              "createdAt": "1997-06-26T00:00:00",
              "ipType": "literature",
              "creators": [
                  {
                      "name": "JK Rowling",
                      "email": "email:JKRowling@example.com",
                      "description": "Author",
                      "contributionPercent": 80,
                      "socialMedia": [
                          {
                              "platform": "Wikipedia",
                              "url": "https://en.wikipedia.org/wiki/J._K._Rowling"
                          }
                      ]
                  },
                  {
                      "name": "Thomas Taylor",
                      "email": "email:ThomasTaylor@example.com",
                      "description": "Illustrator",
                      "contributionPercent": 15
                  },
                  {
                      "name": "Bloomsbury Publishing",
                      "email": "email:BloomsburyPublishing@example.com",
                      "description": "Publisher",
                      "contributionPercent": 5,
                      "socialMedia": [
                          {
                              "platform": "Website",
                              "url": "https://www.bloomsbury.com/"
                          }
                      ]
                  }
              ],
              "media": [
                  {
                      "name": "ePub",
                      "url": "link_to_epub",
                      "mimeType": "application/epub+zip"
                  },
                  {
                      "name": "Book Summary PDF",
                      "url": "link_to_book_summary_pdf",
                      "mimeType": "application/pdf"
                  }
              ],
              "attributes": [
                  {
                      "key": "ISBN",
                      "value": "978-0-7475-3269-0"
                  },
                  {
                      "key": "Genre",
                      "value": "Fantasy"
                  }
              ]
          },
          "onChain": {
              "status": "success",
              "chain": "story-testnet",
              "contractAddress": "0x123",
              "ipAssetId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
              "tokenId": "1",
              "txId": "0x123",
              "explorerLink": "https://explorer.story.foundation/ipa/0xAC6062FF53fa41e61Fe01B89B83d9dB96b5F9280"
          }
      }
      ```
    </CodeGroup>

    Replace `{collectionId}` with your collection ID and `{ipAssetId}` with the IP asset ID returned when you registered the asset. Then run the script:

    <CodeGroup>
      ```bash TypeScript theme={null}
      npx tsx getIPAsset.ts
      ```
    </CodeGroup>
  </Step>
</Steps>

## Confirm Book Registration

<Steps>
  <Step title="Get Action Status">
    You can easily check the IP asset registration status to ensure the action has completed before proceeding.

    <CodeGroup>
      ```typescript getAction.ts theme={null}
      const response = await fetch("https://staging.crossmint.com/api/v1/ip/actions/{actionId}", {
          method: "GET",
          headers: {
              "X-API-KEY": "<YOUR_API_KEY>",
              "Content-Type": "application/json"
          }
      });

      const action = await response.json();
      console.log("Action:", action);
      ```

      ```typescript response theme={null}
      {
          id: '1ffb0fc3-b652-4a0e-b748-3e09c3608826',
          status: 'success'
      }
      ```
    </CodeGroup>

    Use the action ID returned in any of the previous steps and run the script:

    <CodeGroup>
      ```bash TypeScript theme={null}
      npx tsx getAction.ts
      ```
    </CodeGroup>
  </Step>
</Steps>
