A basic/limited PHP client library for connecting to the CityIndex Trading API.
This project has been retired and is no longer being supported by City Index Ltd.
- if you should choose to fork it outside of City Index, please let us know so we can link to your project
<?php
use CityIndex\CIAPI\Core\CIAPIClient;
// Setup a connection to the API endpoint
$client = new CIAPIClient("https://{REST API ENDPOINT}/", '{APP_KEY}', '{APP_VERSION}');
// Create a session
$client->logIn("{username}", "{password}");
// Retrieve some data
$accountInformation = $client->getAccountInformation();
// Use the data
echo $accountInformation->logonUserName ."\n";
// Delete the session
$client->logOut();
CIAPI.PHP requires at least PHP version 5.3.
Furthermore it depends on Requests for PHP, but this dependency is usually handled automatically, see section Installation for details.
NOTE: CIAPI.PHP.phar is currently dysfunctional, so this doesn't work yet!
You can include CIAPI.PHP via a single line as follows:
<?php
require_once 'CIAPI.PHP.phar';
// ...
NOTE: CIAPI.PHP is not yet published via Composer, so this doesn't work yet!
If you're using Composer to manage dependencies, you will be able to add CIAPI.PHP with it as follows:
{
"require": {
"cityindex/ciapi": ">=1.0"
}
}
You can download a generated source archive:
- Download the last successful source code artifacts from the CIAPI.PHP BuildHive project:
$ curl -O https://buildhive.cloudbees.com/job/sopel/job/CIAPI.PHP/lastSuccessfulBuild/artifact/build/dist/CIAPI.PHP.tar.gz
Include it in your scripts via PHP autoloading:
<?php
require_once '<PATH TO DOWNLOAD>/vendor/autoload.php';
You can either clone the repository or download an archive:
- Clone the source code from the CIAPI.PHP Git repository:
$ git clone git://github.com/cityindex/CIAPI.PHP.git
Run the Ant build to fetch dependencies via Composer:
$ ant
Include it in your scripts via PHP autoloading:
<?php
require_once '<PATH TO CLONE>/vendor/autoload.php';
- Alternatively, you can fetch a tarball or zipball from the CIAPI.PHP Git repository:
$ curl https://github.com/cityindex/CIAPI.PHP/tarball/master | tar xzv
(or)
$ wget https://github.com/cityindex/CIAPI.PHP/tarball/master -O - | tar xzv
Run the Ant build to fetch dependencies via Composer:
$ ant
Include it in your scripts via PHP autoloading:
<?php
require_once '<PATH TO DOWNLOAD>/vendor/autoload.php';
A couple of preliminary notes on how to build/test the library:
The build is based on Apache Ant and provides the usual targets clean/build/test/dist, e.g.
$ ant dist
Updating the Composer dependencies modifies the source code and ist handled by a dedicated target accordingly:
$ ant update
There are a few unit tests and some integration tests currently, with the latter requiring CIAPI credentials to be available as environment variables, e.g. (the integration tests are skipped if one or both of these are absent):
$ export CIAPI_USERNAME='<username>'
$ export CIAPI_PASSWORD='<password>'
Copyright 2012 City Index Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.