Count all occurences on a particular field (default on created_at) by a particular period, starting from the first occurence to now.

settings Params

Param name Description
field optional . Must be one of: created_at, updated_at, deleted_at, write_at.

The date field to graph on. Default to created_at.

interval optional . Must be one of: day, week, month, quarter, year, hour_of_day, day_of_week, day_of_month, month_of_year.

The interval to graph by. Default to month_of_year.

sort optional . Must be one of: id, author_id, content, content_html, parent_id, created_at, updated_at, reference_id, deleted_at, is_root, messageable_type, messageable_id, write_at, readings_count.

The sort field. Sorted by created_at asc by default.

Example:

To sort on messages on the fields write_at on a descending order and readings_count on a ascending order:

...&sort=-write_at,readings_count

filter optional . Must be one of: id, author_id, content, content_html, parent_id, created_at, updated_at, reference_id, deleted_at, is_root, messageable_type, messageable_id, write_at, readings_count, deleted, write.

Filtering on one or more fields

Example:

To filter on messages with the id field matching a_value or another_value:

...&filter[id]=a_value,another_value

Filterable fields:
  • id (standard field)
  • author_id (standard field)
  • content (standard field)
  • content_html (standard field)
  • parent_id (standard field)
  • created_at (standard field)
  • updated_at (standard field)
  • reference_id (standard field)
  • deleted_at (standard field)
  • is_root (standard field)
  • messageable_type (standard field)
  • messageable_id (standard field)
  • write_at (standard field)
  • readings_count (standard field)
  • deleted (standard field)
  • write (standard field)
range optional . Must be one of: id, author_id, content, content_html, parent_id, created_at, updated_at, reference_id, deleted_at, is_root, messageable_type, messageable_id, write_at, readings_count.

Select on a particular range

Example:

To range on messages with the readings_count field between min_value and max_value:

...&range[readings_count]=min_value,max_value

Rangeable fields:
  • id
  • author_id
  • content
  • content_html
  • parent_id
  • created_at
  • updated_at
  • reference_id
  • deleted_at
  • is_root
  • messageable_type
  • messageable_id
  • write_at
  • readings_count
comments powered by <span class='logo-disqus'>Disqus</span>
GET /v2/messages/graph/on/created_at/by/week
200
{
  "2014-11-03": 322,
  "2014-11-10": 443,
  "2014-11-17": 401,
  "2014-11-24": 386,
  "2014-12-01": 269,
  "2014-12-08": 192,
  "2014-12-15": 175,
  "2014-12-22": 73,
  "2014-12-29": 279,
  "2015-01-05": 652,
  "2015-01-12": 902,
  "2015-01-19": 560,
  "2015-01-26": 549,
  "2015-02-02": 340,
  "2015-02-09": 295,
  "2015-02-16": 286,
  "2015-02-23": 308,
  "2015-03-02": 342,
  "2015-03-09": 436,
  "2015-03-16": 401,
  "2015-03-23": 509,
  "2015-03-30": 414,
  "2015-04-06": 340,
  "2015-04-13": 396,
  "2015-04-20": 437,
  "2015-04-27": 192,
  "2015-05-04": 290,
  "2015-05-11": 276,
  "2015-05-18": 190,
  "2015-05-25": 176,
  "2015-06-01": 106,
  "2015-06-08": 164,
  "2015-06-15": 253,
  "2015-06-22": 124,
  "2015-06-29": 131,
  "2015-07-06": 119,
  "2015-07-13": 38,
  "2015-07-20": 46,
  "2015-07-27": 31,
  "2015-08-03": 55,
  "2015-08-10": 39,
  "2015-08-17": 31,
  "2015-08-24": 93,
  "2015-08-31": 1459,
  "2015-09-07": 607,
  "2015-09-14": 490,
  "2015-09-21": 362,
  "2015-09-28": 112,
  "2015-10-05": 62,
  "2015-10-12": 762,
  "2015-10-19": 310,
  "2015-10-26": 264,
  "2015-11-02": 210,
  "2015-11-09": 139,
  "2015-11-16": 171,
  "2015-11-23": 424,
  "2015-11-30": 509,
  "2015-12-07": 421,
  "2015-12-14": 314,
  "2015-12-21": 126,
  "2015-12-28": 142,
  "2016-01-04": 282,
  "2016-01-11": 226,
  "2016-01-18": 259,
  "2016-01-25": 174,
  "2016-02-01": 125,
  "2016-02-08": 202,
  "2016-02-15": 164,
  "2016-02-22": 165,
  "2016-02-29": 149,
  "2016-03-07": 184,
  "2016-03-14": 252,
  "2016-03-21": 205,
  "2016-03-28": 148,
  "2016-04-04": 814,
  "2016-04-11": 293,
  "2016-04-18": 352,
  "2016-04-25": 311,
  "2016-05-02": 253,
  "2016-05-09": 424,
  "2016-05-16": 389
}
GET /v2/messages/graph/on/created_at/by/day
200
{
  "2017-11-22": 100
}
curl  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" "https://api.intra.42.fr/v2/messages/graph/on/created_at/by/week"

{
  "2014-11-03": 322,
  "2014-11-10": 443,
  "2014-11-17": 401,
  "2014-11-24": 386,
  "2014-12-01": 269,
  "2014-12-08": 192,
  "2014-12-15": 175,
  "2014-12-22": 73,
  "2014-12-29": 279,
  "2015-01-05": 652,
  "2015-01-12": 902,
  "2015-01-19": 560,
  "2015-01-26": 549,
  "2015-02-02": 340,
  "2015-02-09": 295,
  "2015-02-16": 286,
  "2015-02-23": 308,
  "2015-03-02": 342,
  "2015-03-09": 436,
  "2015-03-16": 401,
  "2015-03-23": 509,
  "2015-03-30": 414,
  "2015-04-06": 340,
  "2015-04-13": 396,
  "2015-04-20": 437,
  "2015-04-27": 192,
  "2015-05-04": 290,
  "2015-05-11": 276,
  "2015-05-18": 190,
  "2015-05-25": 176,
  "2015-06-01": 106,
  "2015-06-08": 164,
  "2015-06-15": 253,
  "2015-06-22": 124,
  "2015-06-29": 131,
  "2015-07-06": 119,
  "2015-07-13": 38,
  "2015-07-20": 46,
  "2015-07-27": 31,
  "2015-08-03": 55,
  "2015-08-10": 39,
  "2015-08-17": 31,
  "2015-08-24": 93,
  "2015-08-31": 1459,
  "2015-09-07": 607,
  "2015-09-14": 490,
  "2015-09-21": 362,
  "2015-09-28": 112,
  "2015-10-05": 62,
  "2015-10-12": 762,
  "2015-10-19": 310,
  "2015-10-26": 264,
  "2015-11-02": 210,
  "2015-11-09": 139,
  "2015-11-16": 171,
  "2015-11-23": 424,
  "2015-11-30": 509,
  "2015-12-07": 421,
  "2015-12-14": 314,
  "2015-12-21": 126,
  "2015-12-28": 142,
  "2016-01-04": 282,
  "2016-01-11": 226,
  "2016-01-18": 259,
  "2016-01-25": 174,
  "2016-02-01": 125,
  "2016-02-08": 202,
  "2016-02-15": 164,
  "2016-02-22": 165,
  "2016-02-29": 149,
  "2016-03-07": 184,
  "2016-03-14": 252,
  "2016-03-21": 205,
  "2016-03-28": 148,
  "2016-04-04": 814,
  "2016-04-11": 293,
  "2016-04-18": 352,
  "2016-04-25": 311,
  "2016-05-02": 253,
  "2016-05-09": 424,
  "2016-05-16": 389
}
curl  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" "https://api.intra.42.fr/v2/messages/graph/on/created_at/by/day"

{
  "2017-11-22": 100
}
require "oauth2"
UID = "Your application uid"
SECRET = "Your application secret"
client = OAuth2::Client.new(UID, SECRET, site: "https://api.intra.42.fr")
token = client.client_credentials.get_token

response = token.get("/v2/messages/graph/on/created_at/by/week")
response.status
# => 200
response.parsed
# => {"2014-11-03"=>322, "2014-11-10"=>443, "2014-11-17"=>401, "2014-11-24"=>386, "2014-12-01"=>269, "2014-12-08"=>192, "2014-12-15"=>175, "2014-12-22"=>73, "2014-12-29"=>279, "2015-01-05"=>652, "2015-01-12"=>902, "2015-01-19"=>560, "2015-01-26"=>549, "2015-02-02"=>340, "2015-02-09"=>295, "2015-02-16"=>286, "2015-02-23"=>308, "2015-03-02"=>342, "2015-03-09"=>436, "2015-03-16"=>401, "2015-03-23"=>509, "2015-03-30"=>414, "2015-04-06"=>340, "2015-04-13"=>396, "2015-04-20"=>437, "2015-04-27"=>192, "2015-05-04"=>290, "2015-05-11"=>276, "2015-05-18"=>190, "2015-05-25"=>176, "2015-06-01"=>106, "2015-06-08"=>164, "2015-06-15"=>253, "2015-06-22"=>124, "2015-06-29"=>131, "2015-07-06"=>119, "2015-07-13"=>38, "2015-07-20"=>46, "2015-07-27"=>31, "2015-08-03"=>55, "2015-08-10"=>39, "2015-08-17"=>31, "2015-08-24"=>93, "2015-08-31"=>1459, "2015-09-07"=>607, "2015-09-14"=>490, "2015-09-21"=>362, "2015-09-28"=>112, "2015-10-05"=>62, "2015-10-12"=>762, "2015-10-19"=>310, "2015-10-26"=>264, "2015-11-02"=>210, "2015-11-09"=>139, "2015-11-16"=>171, "2015-11-23"=>424, "2015-11-30"=>509, "2015-12-07"=>421, "2015-12-14"=>314, "2015-12-21"=>126, "2015-12-28"=>142, "2016-01-04"=>282, "2016-01-11"=>226, "2016-01-18"=>259, "2016-01-25"=>174, "2016-02-01"=>125, "2016-02-08"=>202, "2016-02-15"=>164, "2016-02-22"=>165, "2016-02-29"=>149, "2016-03-07"=>184, "2016-03-14"=>252, "2016-03-21"=>205, "2016-03-28"=>148, "2016-04-04"=>814, "2016-04-11"=>293, "2016-04-18"=>352, "2016-04-25"=>311, "2016-05-02"=>253, "2016-05-09"=>424, "2016-05-16"=>389}
require "oauth2"
UID = "Your application uid"
SECRET = "Your application secret"
client = OAuth2::Client.new(UID, SECRET, site: "https://api.intra.42.fr")
token = client.client_credentials.get_token

response = token.get("/v2/messages/graph/on/created_at/by/day")
response.status
# => 200
response.parsed
# => {"2017-11-22"=>100}