API documentation

API documentation

Account

/messages/list GET

Returns list of messages.

Parameters:

GET data

 

 

folder

(Optional) Folder

Example values: [INBOX|SENT|TRASH]

date_from

(Optional) From datetime

Example value: 2014-12-02 00:00:00

date_to

(Optional) To datetime

Example value: 2014-12-31 23:59:59

unread

(Optional) unread messages

Example value: [yes|no].
- "yes" - unread messages
- "no" - read messages
- empty - read/unread messages

Return values:

SUCCESS

status=SUCCESS, count=[nr of messages], messages=[array of fields]

ERROR

status=ERROR, error=[error message*], errors_list=[input data errors list**]

*[NO MESSAGES|INPUT_DATA]

**[Folder has invalid value|Unread has invalid value|Date From is invalid datetime|Date To is invalid datetime]

Code:

cURL:

curl -H "MicroworkersApiKey:YOUR_API_KEY" -X GET https://api.microworkers.com/messages/list

PHP:

<?php

include "includes/RESTClient.php";
define("cAPI_KEY", "YOUR_API_KEY");
define("cAPI_URL", "https://api.microworkers.com");
$client = new RESTClient();
$client->setApiKey(cAPI_KEY);
$client->setUrl(cAPI_URL . "/messages/list");
$client->setMethod("GET");
$client->execute();
$response = $client->getLastResponse();
$client->resetClient();
echo $response;

?>

Perl:

use MW_API;
use Data::Dumper qw(Dumper);
my $mw_api = MW_API->new('api_key' => 'YOUR_API_KEY');
my $res = $mw_api->do_request('GET', '/messages/list');
print Dumper($res);

Python:

from pprint import pprint
from MW_API import MW_API
mw_api = MW_API('YOUR_API_KEY')
res = mw_api.do_request('GET', '/messages/list')
pprint(res)

C#:

using System;
using MWAPI;

public class Test
{
  public static void Main (string[] args)
  {
    MW_API MW_API_Client = new MW_API ("YOUR_API_KEY");
    string body = MW_API_Client.getRequest("/messages/list");
    Console.WriteLine (body);
  }
}

Examples:

Output (Success):

https://api.microworkers.com/messages/list

{
  "status": "SUCCESS",
  "count": "1",
  "messages": [
    {
      "message_id":"c5237707dcf7",
      "message_type":"",
      "datetime":"2015-01-30 14:23:10",
      "folder":"INBOX",
      "subject":"HG Campaign \"f53ebbf00237\" declined",
      "unread":true,
      "has_attachment":"0"
    }
  ]
}

Output (Error):

https://api.microworkers.com/messages/list

{
  "status": "ERROR",
  "error": "NO MESSAGES"
}