Tak. Vi ringer til dig.
×

Dokumentation til Safetickets API

Using Public API / XML feed

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>
    <venueid>123</venueid>
    <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>
    <customfields>
    </customfields>
  </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>
  <customfields>
    <customfield>
      <name>CUSTOM_ef_92</name>
      <description>Flaf</description>
      <emptyok>false</emptyok>
      <perticket>false</perticket>
      <tickets>all</tickets>
    </customfield>
    <customfield>
      <name>CUSTOM_ef_93</name>
      <description>Gnyf</description>
      <emptyok>true</emptyok>
      <perticket>true</perticket>
      <tickets>86,87</tickets>
    </customfield>
  </customfields>
</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, please contact us at api@safeticket.dk.
We charge an hourly fee of DKK 995,00+VAT for support regarding the API.


Private API

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
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, please contact us at api@safeticket.dk.
We charge an hourly fee of DKK 995,00+VAT for support regarding the API.


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, please contact us at api@safeticket.dk.
We charge an hourly fee of DKK 995,00+VAT for support regarding the API.


Retrieving order details

Retrieving order details via the Safeticket Private API

Single order

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

 

The parameters to send are the following.

version
API version. Always "1".
user
The name of the API user you have created.
orderid
The order ID for which you wish to get details.
sha
The SHA-256 hash.

Pseudocode for calculating the hash:
sha256(concatenate(version, “:”, user, “:”, orderid, “:”, secret))

The call returns details for the order:

<?xml version="1.0" encoding="UTF-8"?>
<orders>
  <order>
    <event>364</event>
    <orderid>9977</orderid>
    <time>2012-10-23 14:51:00</time>
    <paymentsequencenumber>23791</paymentsequencenumber>
    <mailshipping>false</mailshipping>
    <name>Arne Olsen</name>
    <address>Testvej 89</address>
    <address2></address2>
    <zip>8000</zip>
    <city>Aarhus C</city>
    <telephone>12345678</telephone>
    <email>arne@safeticket.dk</email>
    <country>Denmark</country>
    <newsletter>false</newsletter>
    <shippingfee>0.00</shippingfee>
    <cardfee>1.58</cardfee>
    <total>125.33</total>
    <vatamount>24.75</vatamount>
    <status>paid</status>
    <vouchercode>
      <code>secretcode</code>
      <count>5</count>
    </vouchercode>
    <customfields>
      <customfield>
        <name>CUSTOM_class</name>
        <value>3.b</value>
      </customfield>
    </customfields>
    <tickets>
      <ticket>
        <ticketnumber>QMJ3TBUSFN</ticketnumber>
        <ticketid>340</ticketid>
        <price>35.00</price>
        <ticketfee>6.25</ticketfee>
        <arrived>false</arrived>
        <customfields>
          <customfield>
            <name>CUSTOM_name</name>
            <value>Arne Olsen</value>
          </customfield>
        </customfields>
        <seat>
          <row>7</row>
          <seat>1</seat>
        </seat>
      </ticket>
      <ticket>
        <ticketnumber>0OVNS83WLH</ticketnumber>
        <ticketid>340</ticketid>
        <price>35.00</price>
        <ticketfee>6.25</ticketfee>
        <arrived>false</arrived>
        <customfields>
          <customfield>
            <name>CUSTOM_name</name>
            <value>Ole Olsen</value>
          </customfield>
        </customfields>
        <seat>
          <row>7</row>
          <seat>3</seat>
        </seat>
      </ticket>
    </tickets>
  </order>
</orders>

 


Orders in periods

Orders placed during a given period

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

 

 

The parameters to send are the following.

version
API version. Always "1".
user
The name of the API user you have created.
events
The events for which you wish to get order details. Comma separated list of event IDs or 'all'.
sequence_number
(Empty string)
t1
Date specifying the beginning of the period that you wish to get order details for on the format "YYYY-MM-DD".
t2
Date specifying the end of the period that you wish to get order details for on the format "YYYY-MM-DD".
sha
The SHA-256 hash.

Pseudocode for calculating the hash:
sha256(concatenate(version, “:”, user, “:”, events, “:”, sequence_number, “:”, t1, “:”, t2, “:”, secret))

This call returns order details in the same format as the call above that returns details for a single order. The only difference is that there may be more (or none) <order> elements in the response.


Orders since

Orders placed since the last query

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

version
API version. Always "1".
user
The name of the API user you have created.
events
The events for which you wish to get order details. Comma separated list of event IDs or 'all'.
sequence_number
The payment sequence number associated with the last order already retrieved.
t1
(Empty string)
t2
(Empty string)
sha
The SHA-256 hash.

Pseudocode for calculating the hash:
sha256(concatenate(version, “:”, user, “:”, events, “:”, sequence_number, “:”, t1, “:”, t2, “:”, secret))

This call provides a way to periodically poll for new orders.

When an order has been completed it is assigned a payment sequence number. If the order is later refunded it is assigned a new payment sequence number. Payment sequence numbers are assigned as monotonically increasing integers.

The client must keep track of the highest payment sequence number received so far. By sending this number along with the call, only new orders and newly refunded orders will be returned. To get this going initially, you will need to fetch details for a single known order and use the payment sequence number from that order.

This call returns order details in the same format as the call above.

If you have problems or questions, please contact us at api@safeticket.dk.
We charge an hourly fee of DKK 995,00+VAT for support regarding the API.


Issuing tickets via the Safeticket Private API

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

Get reservation token

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

 

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>

 

Get event details

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

 

The parameters to send are the following

version
API version. Always "2".
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.
vouchercode
An optional voucher code. To place an order without using a voucher code, set this value to "".
sha
The SHA-256 hash.

Pseudocode for calculating the hash:
sha256(concatenate(version, “:”, user, “:”, event, “:”, rtoken, “:”, vouchercode, “:”, 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>
  <customfields>
    <customfield>
      <name>CUSTOM_ef_92</name>
      <description>Flaf</description>
      <emptyok>false</emptyok>
      <perticket>false</perticket>
      <tickets>all</tickets>
    </customfield>
    <customfield>
      <name>CUSTOM_ef_93</name>
      <description>Gnyf</description>
      <emptyok>true</emptyok>
      <perticket>true</perticket>
      <tickets>86,87</tickets>
    </customfield>
  </customfields>
</event>

If you have made a request using a voucher code and the code is either invalid or depleted, there will be no tickets listed.

 

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. E.g. "8,2,10,4".
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_ ...
...
T0_CUSTOM_field3
The first custom field for the first ticket.
T0_CUSTOM_field4
The second custom field for the first ticket.
T1_CUSTOM_field3
The first custom field for the second ticket.
T1_CUSTOM_field4
The second custom field for the second ticket.
T2_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, please contact us at api@safeticket.dk.
We charge an hourly fee of DKK 995,00+VAT for support regarding the API.

Har du brug for hjælp? Ring til os på telefon 7020 4720