3. Communication With Clients

This chapter describes the communication that takes place between clients and an independent server, using an independent server demo application as an example. For information on communication between the eShop server and an independent server, see 2. Communication with Nintendo eShop Server.

3.1. Overview

3.1.1. Overview of Independent Server Demo Application

The independent server demo application simulates an independent server being run by a service provider.

The application combines the item information managed on the independent server with the item information obtained from the eShop REST API to create a list of purchasable items and return it to the client.

The client can purchase items selected from the item list and use any licenses that were purchased for available items. The application also provides a database management interface for manipulating the item information and user information managed by the independent server.

3.1.2. Configuring the Independent Server Demo Application

The independent server demo application is provided as a web application that returns an HTML document using HTTP communication. It provides two features: an interface that simulates communication between a game application and an independent server, and a database management interface for the independent server.

The configuration of the independent server demo application, including the game application and eShop REST API, is illustrated below.

Figure 3-1. Configuring the Independent Server Demo Application

For example, if the game application requests an item list, the following kind of process takes place.

  1. The game application wants a list of items available for purchase from the independent server, so it sends a request including a service token.
  2. The independent server gets the title and account information from the service token it received and then, based on that information, requests the item information from the eShop REST API.
  3. The item information received from the eShop REST API is merged with the item information managed inside the independent server to create a list of items available for purchase.
  4. The created item list is then returned to the game application.

Note the following issues when actually building an independent server.

  • Have transactions between the game application and the independent server take place via service tokens.
  • For the communication interface between the game application and the independent server, we recommend sending responses via a REST API or similar means in a format that is easy for the game application to parse, such as XML, JSON, or plain text.
    (The demo application returns an HTML document under the assumption that it will be tested from the browser.)
  • You do not need to provide a database management interface for the independent server to the game application.

3.1.3. Independent Server Demo Application Resources

The following shows the hierarchy of the resources provided by the independent server demo application.

  • http://localhost:8888/v1_0/ 
    • Communication interface between game application and independent server (/rs)
      • Session information (/session)
        • Login (/!open)
        • Logout (/!close)
        • Update cache (/!update)
      • Title information (/titles)
        • List of items available for purchase (/items)
          • Pre-purchase information (/prepurchase_info)
          • Purchase processing and result retrieval (/purchase)
          • Redemption processing and result retrieval (/redeem)
        • List of items available for redemption (/redeem_items)
        • List of recurring billing items (/auto_billing)
        • Specified commercial transactions law message (/law_message)
      • Account information (/accounts)
        • Balance (/balance)
        • Rights for all items (/rights)
          • Rights for a specific item (/item)
            • Consume rights (/consume)
            • List of recurring billing items currently under contract (/auto_billing)
              • Cancel recurring billing item (/cancel)
        • Transactions (/transactions)
          • Payment status (/ext)
Note:

Configure the hostname and context root as appropriate on the independent server. In this document, it is set to http://localhost:8888/v1_0/.


Also, the indepent server demo application is supported by the Swagger UI.
You can confirm API specifications by starting the independent server demo and accessing the following URL.

http://localhost:8888/v1_0/webjars/swagger-ui/2.1.8-M1/index.html?url=http://localhost:8888/v1_0/rs/api-docs


3.1.4. Structure of Independent Server Demo Application Package

The following shows the structure of the package provided in the independent server demo application.

  • java
    • jp.co.nintendo.eshop.demo.server
      • component (Interface for communicating with the eShop REST API and its implementation)
      • config (various application settings)
      • Domain (entity of the database managed by the independent server)
      • enums (enumerated types)
      • exception (exception class)
      • nnas (class that handles service tokens)
      • repository (database access object)
      • restful (controller that provides a communication interface between the game application and the independent server)
      • service (Utility classes for independent server and service classes that communicate with the eShop REST API)
      • util (utility class)
      • web (controller/service class that provides the title and account information management UI)
  • resources (application properties file)
    • messages (message resource group)
    • static (Javascript/CSS file group)
    • templates (HTML template file group)
  • xsd
    • demo (schema that defines the independent server's response format)
    • eshop (schema that defines the eShop REST API's response format)

3.1.5. Authentication

3.1.5.1. Authentication Between the Game Application and the Independent Server

SSL encryption is required for communication between the game application and the independent server. To use encryption, configure the following two items.

  • Embed the server certificate into the independent server.
  • Within the game application, embed a certificate issued by the CA that signed the server certificate.

The following sample procedure shows how to create a self-signed certificate for development using openssl and keytool.

# 1. Create a secret key (server.key).
openssl genrsa 2048 > server.key

# 2. Create a certificate signing request (server.csr).
#  - Enter the requested information after executing the command.
#  - For Common Name, enter the independent server's FQDN.
#  - Enter this CSR in the eShop Web Service Use Application part of the independent server application on OMAS.
openssl req -new -key server.key > server.csr

# 3. Create a server certificate (server.crt).
#  - The following command sets the expiration to ten years.
openssl x509 -days 3650 -req -signkey server.key < server.csr > server.crt

# 4. Convert the server certificate created by OpenSSL (server.pfx) to pkcs12 format.
#  - After the command is executed, a password is requested.
#  - You need the password to embed the server certificate into the independent server.
openssl pkcs12 -export -out server.pfx -inkey server.key -in server.crt

# 5. Using keytool, convert the pkcs12-format server certificate to the jks format (server.keystore).
keytool -importkeystore -srckeystore server.pfx -destkeystore server.keystore -srcstoretype pkcs12 -deststoretype jks

Properly install the created server certificate on the independent server.

The following example uses the Tomcat config file used in the server demo application (%CATALINA_HOME%\conf\server.xml).

<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
           maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
           keystoreFile="C:\server.keystore"
           keystorePass="your_password"
           clientAuth="false" sslProtocol="TLS" />

To use SSL communication between the game application and the independent server, bundle the server certificate created in step 3 with the game application.

 

Note:

To access the server from a Nintendo Web Framework game application, write the content of the server.crt file to ${project.basedir}/app/certificate/ca-bundle.pem.

3.1.6. Service Tokens

In the independent server demo application, the internal server uses the eShop REST API.

To use game applications that access the independent server demo application, depending on the use, get one of the following two service tokens from the account server.

  • Independent server service token
    • The functions provided by the eShop REST API require a principal ID to identify the user. You can get the principal ID by decrypting the service token obtained from the account server on the independent server. To prevent spoofing and other security risks, be sure to get the principal ID from the service token.
    • Service tokens do not expire, and there are no limits on the number of times they can be used. If you configure an expiration in accordance with the independent server's policy, check for expiration based on the token date of issue contained in the service token.
    • If your independent server consists of more than one server machine, you can also share tokens between servers.
  • EC service token
    • Some of the functions in the eShop REST API require an EC service token. When you call one of these functions, you must get an EC service token from the dedicated function in the account library API and send it to the independent server.
    • Do not cache the EC service token in the independent server. Obtain a new one from the account server every time one of these functions is called.

3.1.7. Title Code

The eShop REST API uses the title code as the game title identification ID.

For example, when listing items, specify the title code for the game title to get a list of items related to that title.

The title identifier included in the authentication header when authenticating titles is the same as this title code.

Specify the title codes for Wii U titles in the following format.

1 + [unique ID] + 00 (8-digit hexadecimal)

3.2. API Reference

3.2.1. Retrieving and Decrypting a Service Token

3.2.1.1 Getting a Service Token

For more information about how game applications get independent server service tokens and EC service tokens from the account server, see the account library reference and sample demo in CTR-SDK.

3.2.1.2. Decrypting a Service Token

The following information, including the principal ID, can be retrieved from the decrypted service token.

  • Platform ID
    Information used to identify the platform. On the Wii U, this is always 1.
  • Principal ID
    A constant 32-bit numeric value that is assigned to each Nintendo Network account.
  • Network account ID
    A string of up to 16 alphanumeric characters.
  • Server environment
    A string that identifies the environment of the account server that issued the service token. (Development Hardware: D1, Retail Hardware: L1)
  • Game version
    Version information for each game, managed on the Nintendo account server. (4-digit hexadecimal)
  • Unique ID
    An ID issued by Nintendo to identify a game. This is the same as the ID that is assigned to each title. (5-digit hexadecimal)
  • Token created time
    The UNIX timestamp (milliseconds) of when the token was generated.
  • Authorization code

The unique ID (0xF946D) and client secret (be3d61045441c1bd5fcde232df67c5fb) can be used as samples.

3.2.2. Response From the Independent Server Demo Application

3.2.2.1. Response Format

Table 3-1. Format of the Response From the Independent Server Demo Application
Accept Header Value in Request Content Type of Response
application/xml application/xml
application/json application/json

3.2.2.2. Root Element of the Response

The root element is <eshop> for all responses from applications on the independent server.

Code 3-1. Response Root Element Code
0001  <eshop>
0002    :
0003  </eshop>

3.2.2.3. Error Codes

If execution of the eShop REST API fails for any reason in the independent server demo application, any error information that is returned is passed to the game application unchanged.

Although the implementation of error handling is generally left to the independent server, if an error code is listed in the guidelines for independent servers provided by Nintendo, you must display the message specified in the guidelines in the client application because a user operation is required to recover from the error.

Error codes described in the guidelines can also be referenced from the error code list.

  • Error code format
    109-xxxx(where "xxxx" is a 4-digit decimal number)
Code 3-2. Example of Error Information
0001  <eshop>
0002    <error>
0003      <code>109-1111</code>
0004    </error>
0005  </eshop>

 

3.2.3. Session Information

3.2.3.1. Overview

Log into the independent server and get the session ID of the session that was created. Before using any API element other than the login API, you must first get the session ID from the login API and then include it in the Set-Cookie header (for example, "JSESSIONID=****").

During login, get license information from the eShop REST API server and cache it. The cache can be explicitly updated.

If you logout, the session of the specified session ID is destroyed. Afterward, it will no longer be possible to send any requests or responses using that session ID.

Note:

The independent server demo application is implemented as a stateful web application that uses sessions.

If you want to implement the application as a stateless web application, pass an independent service token as a parameter to all API requests.

3.2.3.2. Request

Table 3-2. Parameters To Specify in Request
Parameter Optional Description
service_token No Independent server service token. Use URL encoding.
lang Yes Language configured in System Settings. Use the language code received from the client. Used to determine the currency display format. If omitted, the system uses the eShop language for the specified Nintendo Network account.

URL

POST http://localhost:8888/v1_0/rs/session/!open?service_token=$service_token
e.g.) POST http://localhost:8888/v1_0/rs/session/!open?service_token=Xe9bEgaeQbD&lang=ja
e.g.) curl -H "Accept:application/xml" -d service_token=Xe9bEgaeQbD -d lang=ja "http://localhost:8888/v1_0/rs/session/!open"

POST http://localhost:8888/v1_0/rs/session/!update
e.g.) POST http://localhost:8888/v1_0/rs/session/!update
e.g.) curl -b "JSESSIONID=hogehoge" -H "Accept:application/xml" "http://localhost:8888/v1_0/rs/session/!update"

POST http://localhost:8888/v1_0/rs/session/!close
e.g.) POST http://localhost:8888/v1_0/rs/session/!close
e.g.) curl -b "JSESSIONID=hogehoge" -H "Accept:application/xml" "http://localhost:8888/v1_0/rs/session/!close"

3.2.3.3. Response

Login API

  • session: Root node for session information.
    • id: Session ID
    • date: Login date and time.
Code 3-3. Sample Response From the Session Information API
0001  <eshop>
0002    <session>
0003      <id>660EC4F8653561F09437168C117E3D2C</id>
0004      <date>2015-09-03T05:02:50Z</date>
0005    </session>
0006  </eshop>

3.2.4. Showing the Item List

3.2.4.1. Overview

This matches the item codes on the list of items maintained by the independent server with those on the list of items obtained through the eShop REST API to get a merged list of items.

If the number of items is large, you can restrict the number of items obtained by specifying an offset value and the maximum number in the list.

3.2.4.2. Request

Table 3-3. Parameters To Specify in Request
Parameter Optional Description
offset Yes Offset for getting service items from the search results that match the filter.
limit Yes Number of service items to get as search results.

URL

GET http://localhost:8888/v1_0/rs/titles/authorized/items?offset=$offset&limit=$limit
e.g.) GET http://localhost:8888/v1_0/rs/titles/authorized/items?offset=0&limit=10

3.2.4.3. Response

  • items: Root node for the service items list.
    • total: Total number of service items matching the search.
    • length: Number of service items included in this response.
    • offset: Offset.
    • item: Service Items.
      • reference_id: Reference ID (32 character hexadecimal).
      • item_name: Item name of the purchased service item (for display in the purchase history).
      • item_description: Details on service item.
      • item_code: The item code for this item.
      • disclaimer: The pre-purchase disclaimer for this item.
      • price: The price for this item.
      • regular_price: The retail price of this item. (Whether tax is included depends on the country.)
        • amount: The retail price formatted for the currency (for example, $10.00).
        • currency: The currency code defined by ISO 4217 (for example, USD).
        • raw_value: The unformatted retail price (for example, 10).
    • tax_excluded: If true, tax is excluded; if false, tax is included. Used to determine whether the price for the relevant item is shown as excluding or including tax when showing the item list.
    • initial_purchase_only: If true, the user cannot purchase an item if the user already has rights to that item's reference ID. You can tell whether the item for a reference ID can be purchased by getting the rights information when listing items.
    • limit: License information for this service item.
      • type: License type for this service item.
      • value: Value corresponding to the license for this item (limited period of time, limited number of times). If the license type is unlimited, this value has no meaning.
    • attributes: List of item attributes.
      • attribute: Item attribute.
        • name: Attribute name.
        • value: Attribute value.

Code 3-4. Sample Response From the Show Item List API
0001  <eshop>
0002    <items>
0003      <length>10</length>
0004      <offset>0</offset>
0005      <total>11</total>
0006      <item>
0007        <item_code>WUPV2EEA00000001</item_code>
0008        <item_name>Sporting event ticket: Soccer</item_name>
0009        <item_description>This ticket lets you watch soccer.</item_description>
0010        <disclaimer>Pre-Purchase Disclaimer. </disclaimer>
0011        <reference_id>0123456789abcdef0000000000000001</reference_id>
0012        <price>
0013          <regular_price>
0014            <amount>0 yen</amount>
0015            <currency>JPY</currency>
0016            <raw_value>0</raw_value>
0017          </regular_price>
0018        </price>
0019        <tax_excluded>false</tax_excluded>
0020        <initial_purchase_only>false</initial_purchase_only>
0021        <limit>
0022          <type>ADDITIONAL TIME</type>
0023          <value>86400</value>
0024        </limit>
0025        <attributes>
0026          <attribute>
0027            <name>PriceType</name>
0028            <value>Free</value>
0029          </attribute>
0030          <attribute>
0031            <name>SaleType</name>
0032            <value>SeasonLimitation</value>
0033          </attribute>
0034        </attributes>
0035      </item>
0036      ...
0037      <item>
0038        <item_code>WUPV2EEA00000004</item_code>
0039          <item_name>500 ml sports drink</item_name>
0040          <item_description>Replenishes your energy. </item_description>
0041        <disclaimer>Pre-Purchase Disclaimer. </disclaimer>
0042        <reference_id>0123456789abcdef0000000000000005</reference_id>
0043        <price>
0044          <regular_price>
0045              <amount>0 yen</amount>
0046            <currency>JPY</currency>
0047            <raw_value>0</raw_value>
0048          </regular_price>
0049        </price>
0050        <tax_excluded>false</tax_excluded>
0051        <initial_purchase_only>false</initial_purchase_only>
0052        <limit>
0053          <type>CONSUMPTION</type>
0054          <value>3</value>
0055        </limit>
0056        <attributes>
0057          <attribute>
0058            <name>PriceType</name>
0059            <value>Free</value>
0060          </attribute>
0061          <attribute>
0062            <name>SaleType</name>
0063            <value>SeasonLimitation</value>
0064          </attribute>
0065        </attributes>
0066      </item>
0067  </eshop>

 

Note:

When setting a country that is not targeted for sales in Nintendo eShop, a response with zero items listed is returned.

3.2.5. Showing Pre-Purchase Information

3.2.5.1. Overview

You can get information about the item specified by the item code before purchase. The kind of information available before purchase includes the item's retail price, the current balance, and the balance after purchase.

The retail price is the item's price as of the receipt of the request. The tax amount appears if the Nintendo Network account's country setting is for a tax-exclusive country.

The tax amount is calculated based on the region of the specified Nintendo Network account.

3.2.5.2. Request

Table 3-4. Parameters To Specify in Request
Parameter Optional Description
item_code No Item code
reference_id No Reference ID (32 character hexadecimal).

URL

GET http://localhost:8888/v1_0/rs/titles/authorized/items/$item_code/prepurchase_info?reference_id=$reference_id
e.g.) http://localhost:8888/v1_0/rs/titles/authorized/items/WUPV2EEA00000001/prepurchase_info?reference_id=0123456789abcdef00000000000000011

3.2.5.3. Response

  • prepurchase_info: Root node of the pre-purchase information.
    • purchasing_item: The item to purchase.
      • reference_id: Reference ID (32-character hexadecimal).
      • item_name: Item name of the purchased service item (for display in the purchase history).
      • item_description: Details of the service item.
      • item_code: The item code for this item.
      • payment_amount: The amount to be paid for the item.
        • price: The retail price of the item.
          • regular_price: The suggested retail price of the item.
            • id: Retail price ID. Used as the price to pay when purchasing the item (price_id).
            • amount: The retail price formatted for the currency (for example, $10.00).
            • currency: The currency code defined by ISO 4217 (for example, USD).
            • raw_value: The unformatted retail price (for example, 10).
        • tax_amount: The tax amount.
          • amount: The tax amount formatted for the currency (for example, $1.50).
          • currency: The currency code defined by ISO 4217 (for example, USD).
          • raw_value: The unformatted tax amount (for example, 1.5).
        • total_amount: The total amount.
          • amount: The total amount formatted for the currency (for example, $11.50).
          • currency: The currency code defined by ISO 4217 (for example, USD).
          • raw_value: The unformatted total amount (for example, 11.5).
    • current_balance: The current balance.
      • amount: The current balance formatted for the currency (for example, $20.00).
      • currency: The currency code defined by ISO 4217 (for example, USD).
      • raw_value: The unformatted current balance (for example, 20).
    • post_balance: The remaining account balance after purchase.
      • amount: The post-purchase account balance formatted for the currency (for example, $20.00).
      • currency: The currency code defined by ISO 4217 (for example, USD).
      • raw_value: The unformatted post-purchase balance (for example, 20).

Code 3-5. Sample Response From the Show Pre-Purchase Information API
0001  <eshop>
0002    <prepurchase_info>
0003      <purchasing_item>
0004        <reference_id>0123456789abcdef0000000000000001</reference_id>
0005        <item_name>Sporting event ticket: Soccer</item_name>
0006        <item_description>This ticket lets you watch soccer.</item_description>
0007        <item_code>WUPV2EEA00000001</item_code>
0008        <payment_amount>
0009          <price>
0010            <regular_price>
0011              <id>2105089201</id>
0012              <amount>0 yen</amount>
0013              <currency>JPY</currency>
0014              <raw_value>0</raw_value>
0015            </regular_price>
0016          </price>
0017          <total_amount>
0018            <amount>0 yen</amount>
0019            <currency>JPY</currency>
0020            <raw_value>0</raw_value>
0021          </total_amount>
0022        </payment_amount>
0023      </purchasing_item>
0024      <current_balance>
0025        <amount>0 yen</amount>
0026        <currency>JPY</currency>
0027        <raw_value>0</raw_value>
0028      </current_balance>
0029      <post_balance>
0030        <amount>0 yen</amount>
0031        <currency>JPY</currency>
0032        <raw_value>0</raw_value>
0033      </post_balance>
0034    </prepurchase_info>
0035  </eshop>

 

3.2.6. Purchasing Items

3.2.6.1. Overview

Purchases the specified item. If the purchase is successful, a license for the relevant item is granted to the specified Nintendo Network account.

3.2.6.2. Request

Table 3-5. Parameters To Specify in Request
Parameter Optional Description
item_code No Item code.
price_id No Price information ID.
reference_id No Reference ID (32 character hexadecimal).
balance No Balance of the account obtained from the balance retrieval function.
ec_service_token No EC service token obtained from account server (Base64 format).

URL

POST http://localhost:8888/v1_0/rs/titles/authorized/items/$item_code/purchase
e.g.) POST http://localhost:8888/v1_0/rs/titles/authorized/items/WUPV2EEA00000001/purchase
price_id=2105089201&reference_id=0123456789abcdef0000000000000001&balance=0&ec_service_token=Xe9bEgaeQbD==&ec_service_token=X82whjghSx=

3.2.6.3. Response

  • transaction_result: Root node for the transaction information.
    • transaction_id: Transaction ID issued by Nintendo.
    • ext_transaction_id: Transaction ID specified by the independent server.
    • item_code: The item code for this item.
    • post_balance: Balance information after the transaction is executed.
      • amount: The account balance formatted for the currency (for example, $10.00).
      • currency: The currency code defined by ISO 4217 (for example, USD).
      • raw_value: The unformatted account balance (for example, 10.0).

Code 3-6. Sample Response From the Item Purchase API
0001  <eshop>
0002    <transaction_result>
0003      <transaction_id>82128415</transaction_id>
0004      <ext_transaction_id>1F946D00rXYwcgXXjchXGiIM2KcODfGsUc</ext_transaction_id>
0005      <item_code>WUPV2EEA00000001</item_code>
0006      <post_balance>
0007        <amount>0 yen</amount>
0008        <currency>JPY</currency>
0009        <raw_value>0</raw_value>
0010      </post_balance>
0011    </transaction_result>
0012  </eshop>

 

3.2.7. Getting License Information

3.2.7.1. Overview

Gets the license information for the specified service title.

Gets the license information for all of the Nintendo Network accounts linked to devices that are tied to the specified Nintendo Network account. Even if the specified Nintendo Network account does not have a license, if another Nintendo Network account associated with the same device does have a license, the system returns the license information for that network account.

3.2.7.2. Request

Table 3-6. Parameters To Specify in Request
Parameter Optional Description
reference_id Yes Reference ID (32 hexadecimal characters). Lowercase alphanumeric [a-f0-9]{32}. If a reference ID is specified, returns only the license information for the relevant reference ID. If not specified, returns the license information for all of the reference IDs for the title.

URL

http://localhost:8888/v1_0/rs/accounts/own/rights/titles/authorized/items/$reference_id
e.g.) GET http://localhost:8888/v1_0/rs/accounts/own/rights/titles/authorized/items/0123456789abcdef0000000000000001

http://localhost:8888/v1_0/rs/accounts/own/rights/titles/authorized
e.g.) GET http://localhost:8888/v1_0/rs/accounts/own/rights/titles/authorized

3.2.7.3. Response

With the Reference ID Specified

  • item_rights: List of rights.
    • reference_id: Reference ID to identify the item purchased (32-character hexadecimal).
    • content_name: Content name of the purchased service item.
    • item_right: The Nintendo Network account that has the license for the item belonging to the specified title.
      • pid: Principal ID for the Nintendo Network account.
      • right_type: License type (permanent, subscription, or consumable).
      • right_value: License according to the license type (for permanent licenses, not used; for subscription licenses, the expiration date; for consumable licenses, the number of uses purchased).
      • auto_billing_applied: Flag indicating whether the item is recurringly billed (Returns null if the title does not support recurring billing).
      • additional_time : Subscription license information (not used for permanent or consumable licenses).
        • current_time : Current date and time issued by independent server.
        • validity : Flag indicating whether the subscription is valid.
      • consumption : Consumable license information (not used for permanent or subscription licenses).
        • total_count: The number of times the license has been used so far.
Code 3-7. Sample Response When a Reference ID Is Specified
0001  <eshop>
0002    <item_rights>
0003      <reference_id>0123456789abcdef0000000000000001</reference_id>
0004      <contnt_name>Sport spectator ticket: Soccer</contnt_name>
0005      <item_right>
0006        <pid>1000000000</pid>
0007        <right_type>ADDITIONAL TIME</right_type>
0008        <right_value>1382582988</right_value>
0009        <auto_billing_applied>false</auto_billing_applied>
0010        <additional_time>
0011          <current_time>1382582987</current_time>
0012          <validity>true</validity>
0013        </additional_time>
0014      </item_right>
0015    </item_rights>
0016  </eshop>

 

With the Reference ID Not Specified

  • rights: Root node of the license information.
    • item_rights: List of licenses.
      • reference_id: Reference ID to identify the item purchased (32-character hexadecimal).
      • content_name: Content name of the purchased service item.
      • item_right: The Nintendo Network account that has the license for the item belonging to the specified title.
        • pid: Principal ID of the Nintendo Network account.
        • right_type: License type (permanent, subscription, or consumable).
        • right_value: License according to the license type (for permanent licenses, not used; for subscription licenses, the expiration date; for consumable licenses, the number of uses purchased).
        • auto_billing_applied: Flag indicating whether the item is recurringly billed (Returns null if the title does not support recurring billing).
        • additional_time: Subscription license information (not used for permanent or consumable licenses).
          • current_time: Current date and time issued by the independent server.
          • validity: Flag indicating whether the subscription is valid.
        • consumption: Consumable license information (not used for permanent or subscription licenses).
          • total_count: The number of times the license has been used so far.
Code 3-8. Sample Response When a Reference ID Is Not Specified
0001  <eshop>
0002    <rights>
0003      <item_rights>
0004        <reference_id>0123456789abcdef0000000000000001</reference_id>
0005      <content_name>Sport spectator ticket: Soccer</content_name>
0006        <item_right>
0007          <pid>1000000000</pid>
0008          <right_type>ADDITIONAL TIME</right_type>
0009          <right_value>1382582988</right_value>
0010          <auto_billing_applied>false</auto_billing_applied>
0011          <additional_time>
0012            <current_time>1382582987</current_time>
0013            <validity>true</validity>
0014          </additional_time>
0015        </item_right>
0016      </item_rights>
0017      <item_rights>
0018        <reference_id>0123456789abcdef0000000000000005</reference_id>
0019          <content_name>500 ml sports drink</content_name>
0020        <item_right>
0021          <pid>1000000000</pid>
0022          <right_type>CONSUMPTION</right_type>
0023          <right_value>3</right_value>
0024          <auto_billing_applied>false</auto_billing_applied>
0025          <consumption>
0026            <total_count>0</total_count>
0027          </consumption>
0028        </item_right>
0029      </item_rights>
0030    </rights>
0031  </eshop>

3.2.8. Consume Rights

3.2.8.1. Overview

Uses the license for the specified consumable item. When the number of uses exceeds the number of licenses held by the network account, the user can no longer use the item.

3.2.8.2. Request

Table 3-7. Parameters To Specify in Request
Parameter Optional Description
reference_id No Reference ID (32 hexadecimal characters). Lowercase alphanumeric [a-f0-9]{32}.
current_toal_count No Times license has been used so far.
consume_count Yes Number to consume. (The default is 1.)

URL

POST http://localhost:8888/v1_0/rs/accounts/own/rights/titles/authorized/items/$reference_id/consume
e.g.) POST http://localhost:8888/v1_0/rs/accounts/own/rights/titles/authorized/items/0123456789abcdef0000000000000005/consume

3.2.8.3. Response

  • consumption_result
    • reference_id: Reference ID to identify the item purchased (32-character hexadecimal).
    • item_right: The network account that has the license for the item belonging to the specified title.
      • pid: Principal ID for the network account.
      • right_type: License type (permanent, subscription, or consumable).
      • right_value: License according to the license type (for permanent licenses, not used; for subscription licenses, the expiration date; for consumable licenses, the number of uses purchased).
      • auto_billing_applied: Flag indicating whether the item is recurringly billed (Returns null if the title does not support recurring billing).
      • consumption: Consumable license information (not used for permanent or subscription licenses).
        • post_count : Times license was used.
        • total_count: The number of times the license has been used so far.
Code 3-9. Sample Response From the Consume License API
0001  <eshop>
0002    <consumption_result>
0003      <reference_id>0123456789abcdef0000000000000005</reference_id>
0004      <item_right>
0005        <pid>1000000000</pid>
0006        <right_type>CONSUMPTION</right_type>
0007        <right_value>3</right_value>
0008        <consumption>
0009          <post_count>1</post_count>
0010          <total_count>1</total_count>
0011        </consumption>
0012      </item_right>
0013    </consumption_result>
0014  </eshop>

3.2.9. Showing Purchase History

3.2.9.1. Overview

Gets the purchase history for the specified Nintendo Network account.

Gets the purchase history for each title code. Also, unlike with the license information retrieval API, you can only get the purchase history for the specified Nintendo Network account.

3.2.9.2. Request

Table 3-8. Parameters To Specify in Request
Parameter Optional Description
offset Yes The offset for all purchase history transactions.
limit Yes The number of purchase history transactions to get.

URL

GET http://localhost:8888/v1_0/rs/accounts/own/transactions?offset=$offset&limit=$limit
e.g.) http://localhost:8888/v1_0/rs/accounts/own/transactions?offset=0&limit=20

3.2.9.3. Response

  • transactions: Root node of the purchase history information.
    • total: Total number of items in the purchase history.
    • length: Number of purchase-history items in this response.
    • offset: The offset.
    • transaction: Purchase-history information.
      • transaction_id: Transaction ID.
      • ext_transaction_id: Transaction ID specified by the independent server.
      • date: Transaction date and time.
      • type: Transaction type (PURCHASE / REDEEM / DELETE).
      • description: Transaction details.
      • transaction_amount: Total amount paid, including tax.
        • amount: The total amount paid, formatted for the currency (for example, $10.00).
        • currency: The currency code defined by ISO 4217 (for example, USD).
        • raw_value: The unformatted total amount paid (for example, 10.0).
      • item: Item information (Returns null if the purchased item has been removed from the catalog.)
        • reference_id: Reference ID to identify the item purchased (32-character hexadecimal).
        • item_name: Item name of the purchased service item (for display in the purchase history).
        • item_code: Item code.
        • limit: License information for this service item.
          • type: License type for this service item.
          • value: Value corresponding to the license for this item (limited period of time, limited number of times). If the license type is unlimited, this value has no meaning.

Code 3-10. Sample Response From the Show Purchase History API
0001  <eshop>
0002    <transactions>
0003      <length>2</length>
0004      <offset>0</offset>
0005      <total>2</total>
0006      <transaction>
0007        <transaction_id>82122097</transaction_id>
0008        <ext_transaction_id>1F946D00UoFITYQWCapLigXQVYmOrc2yqB</ext_transaction_id>
0009        <date>2013-10-23T02:53:01Z</date>
0010        <type>PURCHASE</type>
0011        <description></description>
0012        <transaction_amount>
0013          <amount>0 yen</amount>
0014          <currency>JPY</currency>
0015          <raw_value>0</raw_value>
0016        </transaction_amount>
0017        <item>
0018          <reference_id>0123456789abcdef0000000000000005</reference_id>
0019          <item_name>500 ml sports drink</item_name>
0020          <item_code>WUPV2EEA00000004</item_code>
0021          <limit>
0022            <type>CONSUMPTION</type>
0023            <value>3</value>
0024          </limit>
0025        </item>
0026      </transaction>
0027      <transaction>
0028        <transaction_id>82128415</transaction_id>
0029        <ext_transaction_id>1F946D00rXYwcgXXjchXGiIM2KcODfGsUc</ext_transaction_id>
0030        <date>2013-10-23T02:49:48Z</date>
0031        <type>PURCHASE</type>
0032        <description></description>
0033        <transaction_amount>
0034            <amount>0 yen</amount>
0035          <currency>JPY</currency>
0036          <raw_value>0</raw_value>
0037        </transaction_amount>
0038        <item>
0039          <reference_id>0123456789abcdef0000000000000001</reference_id>
0040      <item_name>Sport spectator ticket: Soccer</item_name>
0041          <item_code>WUPV2EEA00000001</item_code>
0042          <limit>
0043            <type>ADDITIONAL TIME</type>
0044            <value>1382582988</value>
0045          </limit>
0046        </item>
0047      </transaction>
0048    </transactions>
0049  </eshop>

 


CONFIDENTIAL