• Dokumentation til Safetickets API

    Denne dokumentation er primært henvendt til udviklere og er derfor på engelsk af hensyn til udenlandske udviklere.

    Shortcuts on this page:

    - Public API
    - Private API
    - Retrieve ticketsale statistics
    - Issue tickets

    Using the Safeticket Public API / XML feed


    Introduction

    The Safeticket API provides a way to automatically get details about events, maintained by the customer in our database. Before you can use the public API it must first be activated by Safeticket.

    Methods

    There are basically two ways to fetch updated information about events.

    - Periodically fetch everything with the "all" method.
    - Periodically fetch the list of events with the "list" method and use the "modified" timestamps to determine the events that need updating. Then fetch each of these events using the "event" method.

    All calls are done via https to the domain belonging to the given customer. If the domain is example.com and we e.g. want to call the "all" method, the URL to call will be "https://example.com/api/all".

    All

    URL: https://example.com/api/all

    This call returns details for all events:

    <?xml version="1.0" encoding="UTF-8"?>
    <events>
      <event id="152">
        <modified>2010-10-25T08:33:13+0200</modified>
        <title>Test 42</title>
        <venue>Some venue</venue>
        <city>Aarhus</city>
        <category>Concerts</category>
        <date>2010-11-10</date>
        <time>19:00:00</time>
        <insale>true</insale>
        <soldout>false</soldout>
        <infourl>https://example.com/events/152-Test_42/</infourl>
        <buyurl>https://example.com/events/152-Test_42/ticket</buyurl>
        <teaser>Test</teaser>
        <description>Test</description>
        <photosmall>
          https://example.com/filestore/17b1ab0f6f6cd80bbdaf6decd13
        </photosmall>
        <photolarge>
          https://example.com/filestore/85e7c8701663a96e119a34518d4
        </photolarge>
        <ticketselection>count</ticketselection>
        <tickets>
          <ticket id="86">
    	<name>Gnyf</name>
    	<section>Section</section>
    	<seatmap></seatmap>
    	<type>Standing</type>
    	<price>10.00</price>
            <ticketfee>6.25</ticketfee>
            <shippingfee>30.00</shippingfee>
    	<currency>DKK</currency>
            <vat>25%</vat>
          </ticket>
          <ticket id="87">
    	<name>Plop</name>
    	<section>Section</section>
    	<seatmap></seatmap>
    	<type>Standing</type>
    	<price>5.00</price>
            <ticketfee>6.25</ticketfee>
            <shippingfee>30.00</shippingfee>
    	<currency>DKK</currency>
            <vat>25%</vat>
          </ticket>
        </tickets>
      </event>
    ...
    </events>
    

    List

    URL: https://example.com/api/list

    This call returns the list of all events along with the time of last modification:

    <?xml version="1.0" encoding="UTF-8"?>
    <events>
      <event id="152">
        <modified>2010-10-25T08:33:13+0200</modified>
        <detailsurl>https://example.com/api/events/152</detailsurl>
      </event>
      <event id="12">
        <modified>2010-10-25T08:33:13+0200</modified>
        <detailsurl>https://example.com/api/events/12</detailsurl>
      </event>
    ...
    </events>
    

    Event

    URL: https://example.com/api/events/<ID>

    This call returns the details for one specific event:

    <?xml version="1.0" encoding="UTF-8"?>
    <event id="152">
      <modified>2010-10-25T08:33:13+0200</modified>
      <title>Test 42</title>
      <venue>Some venue</venue>
      <city>Aarhus</city>
      <category>Concerts</category>
      <date>2010-11-10</date>
      <time>19:00:00</time>
      <insale>true</insale>
      <soldout>false</soldout>
      <infourl>https://example.com/events/152-Test_42/</infourl>
      <buyurl>https://example.com/events/152-Test_42/ticket</buyurl>
      <teaser>Test</teaser>
      <description>Test</description>
      <photosmall>
        https://example.com/filestore/17b1ab0f6f6cd80bbdaf6decd13
      </photosmall>
      <photolarge>
        https://example.com/filestore/85e7c8701663a96e119a34518d4
      </photolarge>
      <ticketselection>count</ticketselection>
      <tickets>
        <ticket id="86">
          <name>Gnyf</name>
          <section>Section</section>
          <seatmap></seatmap>
          <type>Standing</type>
          <price>10.00</price>
          <ticketfee>6.25</ticketfee>
          <shippingfee>30.00</shippingfee>
          <currency>DKK</currency>
          <vat>25%</vat>
        </ticket>
        <ticket id="87">
          <name>Plop</name>
          <section>Section</section>
          <seatmap></seatmap>
          <type>Standing</type>
          <price>5.00</price>
          <ticketfee>6.25</ticketfee>
          <shippingfee>30.00</shippingfee>
          <currency>DKK</currency>
          <vat>25%</vat>
        </ticket>
      </tickets>
    </event>
    

    Notes

    The intended use of this facility is to allow updating a local database that can be used when presenting the information.

    Requesting the XML files or images from our servers on every page view is strongly discouraged.

    If you have problems or questions, feel free to contact us at api@safeticket.dk.

    Go to the top

  • Using the Safeticket Private API

    Before you can use the private API it must first be activated by Safeticket after which you have to create one or more API users.

    After logging in choose "Administration" in the menu and click "oprette en ny API bruger".

    "Brugernavn" is important as that is what is used when accessing the API for identifying the user. Pay attention to the permissions as well and make sure to adjust them appropriately.

    When you are done and have created the user open the user for editing and note the field "Hemmelighed".

    The username and secret make up your credentiels for private API access.

    API methods are invoked by a HTTP POST request having the needed parameters encoded as regular POST fields. All values are to be sent UTF-8 encoded.

    Authentication is based on a hash of the parameters sent to a given API method concatenated together with the secret. It is important to calculate the hash using all the parameters separated by the correct delimiter.

    Here is an example of the hash calculation for a call to the "/api/stats" method. The parameters that are sent are the following.

    version 1
    user webshop
    cash 0
    t1 2011-10-01
    t2 2011-11-01
    sha 79a7f895e442b5c0e17323a4a3eab17a88c457c299342ea25381939f7a0d5a06


    In order to calculate the hash we first need to build the string that will be fed to the hash function.
    To build this string we concatenate all the parameters as well as the secret and separate them with ":".
    In pseudocode: concatenate(version, ":", user, ":", cash, ":", t1, ":", t2, ":", secret)

    The string in this example then looks like this: "1:webshop:0:2011-10-01:2011-11-01:7ba7fbff4ef6933974c8c82b9419b6706338be8ab40d556980cbdfac5d868d20"

    We then calculate the SHA-256 hash of the string:
    sha256("1:webshop:0:2011-10-01:2011-11-01:7ba7fbff4ef6933974c8c82b9419b6706338be8ab40d556980cbdfac5d868d20")

    The result is the string "79a7f895e442b5c0e17323a4a3eab17a88c457c299342ea25381939f7a0d5a06" which is sent as the "sha" parameter.

    When the request has been successfully handled you will get an XML document as response.

    If you have problems or questions, feel free to contact us at api@safeticket.dk.

    Go to the top

  • Retrieving ticketsale statistics via the Safeticket Private API


    All events

    URL: https://example.com/api/stats

    The parameters to send are the following.

    version API version. Always "1".
    user The name of the API user you have created.
    cash "0" or "1". Controls whether cash payments are included in the result.
    t1 Date specifying the beginning of the period that you wish to retrieve statistics for on the format "YYYY-MM-DD".
    t2 Date specifying the end of the period that you wish to retrieve statistics for on the format "YYYY-MM-DD".
    sha The SHA-256 hash.


    Pseudocode for calculating the hash:
    sha256(concatenate(version, ":", user, ":", cash, ":", t1, ":", t2, ":", secret))

    This call returns statistics for all events:

    <?xml version="1.0" encoding="UTF-8"?>
    <events t1="2011-10-01" t2="2011-11-01">
      <event id="241">
        <refunded>
        </refunded>
        <ticketfees>
          <fee>
    	<amount>6.25</amount>
    	<currency>DKK</currency>
    	<count>1</count>
          </fee>
          <fee>
    	<amount>-6.25</amount>
    	<currency>DKK</currency>
    	<count>1</count>
          </fee>
        </ticketfees>
        <shipping>
          <count>0</count>
          <fee>0.00</fee>
        </shipping>
        <tickets>
          <ticket id="166">
    	<name>Elevbillet</name>
    	<prices>
    	  <price>
    	    <amount>100.00</amount>
    	    <currency>DKK</currency>
    	    <count>1</count>
    	  </price>
    	</prices>
          </ticket>
        </tickets>
      </event>
      <event id="26">
        <refunded>
        </refunded>
        <ticketfees>
          <fee>
    	<amount>6.25</amount>
    	<currency>DKK</currency>
    	<count>3</count>
          </fee>
          <fee>
    	<amount>-6.25</amount>
    	<currency>DKK</currency>
    	<count>3</count>
          </fee>
        </ticketfees>
        <shipping>
          <count>0</count>
          <fee>0.00</fee>
        </shipping>
        <tickets>
          <ticket id="26">
    	<name>Elevbillet</name>
    	<prices>
    	  <price>
    	    <amount>100.00</amount>
    	    <currency>DKK</currency>
    	    <count>2</count>
    	  </price>
    	</prices>
          </ticket>
          <ticket id="31">
    	<name>Ølbillet</name>
    	<prices>
    	  <price>
    	    <amount>1.00</amount>
    	    <currency>DKK</currency>
    	    <count>1</count>
    	  </price>
    	</prices>
          </ticket>
        </tickets>
      </event>
    </events>
    
    Single event

    URL: https://example.com/api/stats/<ID>

    The parameters to send are the following.

    version API version. Always "1".
    user The name of the API user you have created.
    event The event ID for which you wish to retrieve statistics.
    cash "0" or "1". Controls whether cash payments are included in the result.
    sha The SHA-256 hash.


    Pseudocode for calculating the hash:
    sha256(concatenate(version, ":", user, ":", event, ":", cash, ":", secret))

    This call returns statistics for a single event:

    <?xml version="1.0" encoding="UTF-8"?>
    <event id="26">
      <refunded>
        <ticket id="26">
          <name>Elevbillet</name>
          <prices>
            <price>
              <amount>1000.00</amount>
              <currency>DKK</currency>
              <count>65</count>
            </price>
            <price>
              <amount>100.00</amount>
              <currency>DKK</currency>
              <count>65</count>
            </price>
          </prices>
        </ticket>
        <ticket id="31">
          <name>Ølbillet</name>
          <prices>
            <price>
              <amount>1.00</amount>
              <currency>DKK</currency>
              <count>24</count>
            </price>
          </prices>
        </ticket>
      </refunded>
      <ticketfees>
        <fee>
          <amount>6.25</amount>
          <currency>DKK</currency>
          <count>97</count>
        </fee>
        <fee>
          <amount>10.00</amount>
          <currency>DKK</currency>
          <count>57</count>
        </fee>
        <fee>
          <amount>-6.25</amount>
          <currency>DKK</currency>
          <count>261</count>
        </fee>
      </ticketfees>
      <shipping>
        <count>0</count>
        <fee>0.00</fee>
      </shipping>
      <tickets>
        <ticket id="26">
          <name>Elevbillet</name>
          <prices>
            <price>
              <amount>1000.00</amount>
              <currency>DKK</currency>
              <count>65</count>
            </price>
            <price>
              <amount>100.00</amount>
              <currency>DKK</currency>
              <count>65</count>
            </price>
          </prices>
        </ticket>
        <ticket id="31">
          <name>Ølbillet</name>
          <prices>
            <price>
              <amount>1.00</amount>
              <currency>DKK</currency>
              <count>24</count>
            </price>
          </prices>
        </ticket>
      </tickets>
    </event>
    

    If you have problems or questions, feel free to contact us at api@safeticket.dk.

    Go to the top

  • Issuing tickets via the Safeticket Private API


    Issuing tickets via the API is a five step process:
    • Get event details
    • Get reservation token
    • Reserve tickets
    • Place order
    • Confirm payment

    Get event details

    URL: https://example.com/api/ticket/eventdetails

    The parameters to send are the following.

    version API version. Always "1".
    user The name of the API user you have created.
    event The event ID for which you wish to issue tickets.
    sha The SHA-256 hash.


    Pseudocode for calculating the hash:
    sha256(concatenate(version, ":", user, ":", event, ":", secret))

    This call returns details for the event:

    <?xml version="1.0" encoding="UTF-8"?>
    <event id="152">
      <modified>2010-10-25T08:33:13+0200</modified>
      <title>Test 42</title>
      <venue>Some venue</venue>
      <city>Aarhus</city>
      <category>Concerts</category>
      <date>2010-11-10</date>
      <time>19:00:00</time>
      <insale>true</insale>
      <soldout>false</soldout>
      <infourl>https://example.com/events/152-Test_42/</infourl>
      <buyurl>https://example.com/events/152-Test_42/ticket</buyurl>
      <teaser>Test</teaser>
      <description>Test</description>
      <photosmall>
        https://example.com/filestore/17b1ab0f6f6cd80bbdaf6decd13
      </photosmall>
      <photolarge>
        https://example.com/filestore/85e7c8701663a96e119a34518d4
      </photolarge>
      <ticketselection>count</ticketselection>
      <tickets>
        <ticket id="86">
          <name>Gnyf</name>
          <section>Section</section>
          <seatmap></seatmap>
          <type>Standing</type>
          <price>10.00</price>
          <ticketfee>6.25</ticketfee>
          <shippingfee>30.00</shippingfee>
          <currency>DKK</currency>
          <vat>25%</vat>
        </ticket>
        <ticket id="87">
          <name>Plop</name>
          <section>Section</section>
          <seatmap></seatmap>
          <type>Standing</type>
          <price>5.00</price>
          <ticketfee>6.25</ticketfee>
          <shippingfee>30.00</shippingfee>
          <currency>DKK</currency>
          <vat>25%</vat>
        </ticket>
      </tickets>
    </event>
    
    Get reservation token

    URL: https://example.com/api/ticket/gettoken

    The parameters to send are the following.

    version API version. Always "1".
    user The name of the API user you have created.
    event The event ID for which you wish to issue tickets.
    aggressive_timeout "0" or "1". Controls whether to enable agressive timeout.
    sha The SHA-256 hash.


    Pseudocode for calculating the hash:
    sha256(concatenate(version, ":", user, ":", event, ":", aggressive_timeout, ":", secret))

    This call returns an rtoken value as well as the availability status of all the tickets for the event:

    <?xml version="1.0" encoding="UTF-8"?>
    <gettoken>
      <rtoken id="02246c57555d59c3d8062690c051b8b1" />
      <ticket id="10" available="true" />
      <ticket id="91" available="true" />
      <ticket id="12" available="true" />
      <ticket id="126" available="true" />
      <ticket id="112" available="false" />
      <ticket id="8" available="true" />
    </gettoken>
    
    Reserve tickets

    URL: https://example.com/api/ticket/reserve

    The parameters to send are the following.

    version API version. Always "1".
    user The name of the API user you have created.
    event The event ID for which you wish to issue tickets.
    rtoken The rtoken value returned from the call to /api/gettoken.
    tickets Comma separated list of ticket IDs and counts.
    sha The SHA-256 hash.


    Pseudocode for calculating the hash:
    sha256(concatenate(version, ":", user, ":", event, ":", rtoken, ":", tickets, ":", secret))

    This call returns the tickets actually reserved as a result of the call:

    <?xml version="1.0" encoding="UTF-8"?>
    <reserve>
      <ticket id="112" count="0" />
      <ticket id="8" count="2" />
      <ticket id="10" count="4" />
      <ticket id="91" count="0" />
      <ticket id="12" count="0" />
      <ticket id="126" count="0" />
    </reserve>
    
    Place order

    URL: https://example.com/api/ticket/placeorder

    The parameters to send are the following.

    version API version. Always "1".
    user The name of the API user you have created.
    rtoken The rtoken value returned from the call to /api/gettoken.
    total Total price in øre.
    name Order name
    address Order address
    address2 Order address2
    zip Order zip
    city Order city
    telephone Order telephone
    email Order email
    country Order country
    cardtype Always "".
    newsletter "0" or "1". Indicates whether the buyer of the tickets accepts receiving a newsletter.
    shippingmail "0" or "1". Indicates whether the buyer of the tickets has chosen to get the tickets mailed.
    CUSTOM_field1 The first custom field for the event.
    CUSTOM_field2 The second custom field for the event.
    CUSTOM_ ... ...
    sha The SHA-256 hash.


    Pseudocode for calculating the hash:
    sha256(concatenate(version, ":", user, ":", rtoken, ":", total, ":", name, ":", address, ":", address2, ":", zip, ":", city, ":", telephone, ":", email, ":", country, ":", cardtype, ":", newsletter, ":", shippingmail, ":", CUSTOM_field1, ":", CUSTOM_field2, ":", CUSTOM_ ... , ":", secret))

    This call places the order and returns the status and the order number:

    <?xml version="1.0" encoding="UTF-8"?>
    <placeorder>
    <status>OK</status>
    <order>7290</order>
    </placeorder>
    
    Confirm payment

    URL: https://example.com/api/ticket/confirmpayment

    The parameters to send are the following.

    version API version. Always "1".
    user The name of the API user you have created.
    rtoken The rtoken value returned from the call to /api/gettoken.
    orderid The order number from the call to /api/placeorder.
    transaction Transaction number from the payment. Optional.
    cardnumber Masked card number from the payment. Optional.
    sendmail "0" or "1". Controls whether Safeticket should send an order confirmation mail.
    sha The SHA-256 hash.


    Pseudocode for calculating the hash:
    sha256(concatenate(version, ":", user, ":", rtoken, ":", orderid, ":", transaction, ":", cardnumber, ":", sendmail, ":", secret))

    This call marks the order as paid and returns the link to the ticket PDF:

    <?xml version="1.0" encoding="UTF-8"?>
    <confirmpayment>
      <status>OK</status>
      <ticketpdf>
        https://example.com/pdf?id=7290&mailid=55350cdb4155c2c4d7292c87048adbe6d7044bbb206516a479d8022c77031034b73e7b8d386c9e9a0aa411bdc66ff4f2
      </ticketpdf>
    </confirmpayment>
    

    If you have problems or questions, feel free to contact us at api@safeticket.dk.

    Go to the top