2

For anyone who worked with Freelancer.com Api. I trying to fetch all active projects from this platform by API and sort them by recent post date, by default there is sorting by score. There is nothing said about what sort_field value must be to sort by recent post date.

$sorting_date = "????"; 
$requestUrl = "https://www.freelancer.com/api/projects/0.1/projects/active/?sort_field=" . $sorting_field;
$response = json_decode(file_get_contents($requestUrl), 1);

Here is link to API documentation: Freelancer.com API

Maybe anyone had the same problem?Need help.

Dmitriy Buteiko
  • 624
  • 1
  • 6
  • 14

2 Answers2

2

Answer In short: You can use https://www.freelancer.com/api/projects/0.1/projects/active/ without using the sort_field because it is also sorted in recent post by default

Explanation I tested the API and I found that this is also sorted recent posted date for submitted date

According to Freelancer's Documentation:

Sorting field, by default searches by score, otherwise most recently posted.

I try to limit the result to 3 and reverse it using reverse_sort to test if it's actually working. https://www.freelancer.com/api/projects/0.1/projects/active/?limit=3&reverse_sort=true

$requestUrl = "https://www.freelancer.com/api/projects/0.1/projects/active/?limit=3&reverse_sort=true";
$response = json_decode(file_get_contents($requestUrl), 1);
echo "<pre>";
var_dump($response);

Here is the result.

Search for ["submitdate"] by pressing CRTL + F and get the value.

Paste the value here to convert the equivalent date

Here is the result of reverse_sort converted date

Wed Sep 03 2014 21:14:19 GMT+0800 
Tue Jul 14 2015 23:11:36 GMT+0800
Fri Jul 24 2015 05:46:41 GMT+0800

If we remove the reverse_sort=true here is the result

Fri Dec 29 2017 12:45:13 GMT+0800
Fri Dec 29 2017 12:44:49 GMT+0800
Fri Dec 29 2017 12:44:29 GMT+0800

As you can see it is sort by recent posted date

Bluetree
  • 1,324
  • 2
  • 8
  • 25
0

Could you try something like this? This would return projects related to C# ordered by their id.

https://www.freelancer.com/api/projects/0.1/projects/active?jobs[]=106&sort_field=id
Floern
  • 33,559
  • 24
  • 104
  • 119