Difference between revisions of "API: Getting started"

From Star Wars Combine :: Game Guide
Jump to: navigation, search
m (A first sample)
(API root)
 
Line 23: Line 23:
 
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, there's a working copy on [[http://dev.swcombine.com/ws/v1.0/developers/index.php the dev server]].)
 
  
 
It comes in handy once in a while, but for now you can safely ignore it.
 
It comes in handy once in a while, but for now you can safely ignore it.

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.