collection.create

Create a new collection to store texts in.

Request Parameters

nameString (required)

The name for the collection being created. Maximum 100 chars.

languageString (required)

Specify what language the texts that will be stored in the collection are written in. English and Swedish are supported and specified according to ISO 639-1. Swedish = "sv", English = "en".

descriptionString

Provide a description for your new collection. Maximum 250 chars. Tip: Use something that describes what the collection will contain (e.g. Blog posts from my personal blog)

Response Parameters

collection_idint
The id for your created collection.
nameString
The name of the collection.
languageString

The language allowed for texts stored in the collection. Specified according to ISO 639-1

descriptionString
Description of the collection.

Code Examples

JSON

//Request
{
  "method": "collection.create", 
  "params": {
    "name": "My Text Collection", 
    "description": "Collection for english blog posts", 
    "language": "en"
  }, 
  "id": 0
}

//Response
{
  "collection_id": 606,
  "description": "Collection for english blog posts",
  "name": "My Text Collection", 
  "language": "en",
  "next_id": 213
}

Java


// You need to have a ready-to-use client to use the other methods
SaploClient client = new SaploClient("YOUR_API_KEY", "YOUR_SECRET_KEY");

// Create a SaploCollectionManager to work with collections
SaploCollectionManager collectionMgr = new SaploCollectionManager(client);

// Create a Collection object
SaploCollection collection = new SaploCollection("COLLECTION_NAME", Language.en);

// Save/create your collection on the Saplo-API
collectionMgr.create(collection);

// Your collection gets a generated ID number from the API
System.out.println("This is the ID of my collection: " + collection.getId());

PHP


$client = new SaploAPI("YOUR API KEY", "YOUR SECRET KEY");

//Set parameters
$params = array(
    "name" => "My Collection",
    "description" => "This is my first collection for english texts.",
    "language" => "en"
);

//Run method
try {
    $result = $client->collection->create($params);
} catch(SaploException $e) {
    echo '(' . $e->getCode() . ') ' . $e->getMessage();
}

//Print result
var_dump($result);

Python


client = SaploJSONClient("YOUR API KEY", "YOUR SECRET KEY")

collection_id = client.collection.create(
    name = "My Collection",
    description = "This is my first collection for english texts.",
    language = "en"
)

print "New collection created with Id:", collection_id

cURL


curl -d '{"method":"collection.create", "params":{"name":"Example Collection", "language":"en"}, "id":0}' 'http://api.saplo.com/rpc/json?access_token=AT5934226286152414351N'

Matlab

params.name = 'My First Collection';
params.language = 'en';

response = saploRequest('collection.create', params);

sprintf('Collection id %s \n', response.collection_id);

Notes

A collection is a container to store texts in. A collection can only contain texts with the same language (e.g. only english texts in the collection).