Difference between revisions of "API: Getting started"

From Star Wars Combine :: Game Guide
Jump to: navigation, search
m (API root)
(API root)
 
(8 intermediate revisions by the same user not shown)
Line 18: Line 18:
 
You access the API via a directory tree on the SWC website. Root directory is
 
You access the API via a directory tree on the SWC website. Root directory is
  
http://www.swcombine.com:8081/ws/v1.0/
+
http://www.swcombine.com/ws/v1.0/
  
  
 
Yes, give it a try. It won't explode in your face ... I hope. Not often, anyway.
 
Yes, give it a try. It won't explode in your face ... I hope. Not often, anyway.
  
The XML response to this URI is the API's index resource, which also poses as source code for the documentation, which is currently unavailable on the main server.
+
The XML response to this URI is the API's index resource, which also poses as source code for the documentation.
  
(If you insist on seeing it, sign up on [[http://dev.swcombine.com the dev server]] and [[http://dev.swcombine.com/ws/v1.0/developers/index.php check this]])
+
It comes in handy once in a while, but for now you can safely ignore it.
  
Lots and lots of XML stuff. It does come in handy once in a while, but for now you can safely ignore it.
+
You might think that's an impressive list of features. It is. Unfortunately, a lot of them don't work. But a few very useful ones do.
  
 
== A first sample ==
 
== A first sample ==
Line 33: Line 33:
 
Let's dig a wee bit deeper and try one of the public resources. No, not "hello world", but:
 
Let's dig a wee bit deeper and try one of the public resources. No, not "hello world", but:
  
    http://www.swcombine.com:8081/ws/v1.0/api/time/real/
+
http://www.swcombine.com/ws/v1.0/api/time/real/
  
  
Line 60: Line 60:
 
Note that <code>timestamp-swc</code> is SWC's variant of unix time.
 
Note that <code>timestamp-swc</code> is SWC's variant of unix time.
  
You will discover, that you can convert an SWC timestamp into a regular unix timestamp by adding a constant value of 912668400.  
+
You will discover, that you can convert a <code>timestamp-swc</code> into a regular unix timestamp by adding a constant value of 912668400.  
  
 
So, whenever you encounter a <code>timestamp-swc</code>, you'll know what to do.
 
So, whenever you encounter a <code>timestamp-swc</code>, you'll know what to do.
 +
 +
 +
 +
Okay, that was easy, wasn't it? Now let's try [[API:_Handle_verification|something ''really'' useful]].

Latest revision as of 01:17, 18 September 2017

API?

API means Application Programming Interface, but you probably knew that already.

The Combine API allows direct access to the Combine's database from your application program. Not all of it, though, and not right away, it's not that simple.

There are public resources and there are private resources.

"Private" means, you'd access via a specific character's scope. That requires proper authentication, of course, and it's not exactly trivial.

So we'll focus on a few public resources for now, not only to get into the right mood but also because there's quite some nifty stuff available.


API root

You access the API via a directory tree on the SWC website. Root directory is

http://www.swcombine.com/ws/v1.0/


Yes, give it a try. It won't explode in your face ... I hope. Not often, anyway.

The XML response to this URI is the API's index resource, which also poses as source code for the documentation.

It comes in handy once in a while, but for now you can safely ignore it.

You might think that's an impressive list of features. It is. Unfortunately, a lot of them don't work. But a few very useful ones do.

A first sample

Let's dig a wee bit deeper and try one of the public resources. No, not "hello world", but:

http://www.swcombine.com/ws/v1.0/api/time/real/


Response:

<?xml version="1.0" encoding="UTF-8"?>
<timereal xmlns="http://www.swcombine.com/ws/timereal-ns/" version="1.0" timestamp-swc="[swcTime]">
  <timestamp-unix>[realTime]</timestamp-unix>
</timereal>


There we go.

All API responses follow the same pattern: There is a proper XML header and a root element with a unique name, suitable to identify the resource you're looking at, and a few standard attributes like

- the XML name space xmlns

- the API version version and

- the SWC timestamp timestamp-swc, when this response was created.


Note that timestamp-swc is SWC's variant of unix time.

You will discover, that you can convert a timestamp-swc into a regular unix timestamp by adding a constant value of 912668400.

So, whenever you encounter a timestamp-swc, you'll know what to do.


Okay, that was easy, wasn't it? Now let's try something really useful.