Getting Started with Freelancer.com API

If you're looking to integrate your application or website with Freelancer.com, the first step is to use their public API. In this guide, we'll walk you through getting started with Freelancer.com API and provide some examples in JavaScript.

Registering for Freelancer.com API

To use Freelancer.com API, you'll need to create an account with Freelancer.com first and obtain an API key. Here's how you can do it:

  1. Go to https://www.freelancer.com
  2. Click on the "Sign Up" button at the top right corner
  3. Follow the registration process and create an account
  4. Once you have an account, go to https://www.freelancer.com/developers and click on "Get API Key"
  5. Fill out the required information and accept the terms and conditions
  6. Your API key will be displayed on the screen. Make sure to keep it secure.

API Examples in JavaScript

Now that you have an API key, you can start making requests to Freelancer.com's API. Freelancer.com API documentation provides sample code in various languages. Below are some examples in JavaScript:

Retrieve User Information

Get user information using their user ID.

const fetch = require("node-fetch");

const userID = "123456"; // the user ID of the user you want to retrieve info for
const apiKey = "MY_API_KEY"; // replace with your own API key

fetch(`https://www.freelancer.com/api/users/0.1/users/${userID}?compact=true`, {
    headers: {
        "Freelancer-Developer-OAuth-Client-Id": apiKey
    }
})
.then(response => response.json())
.then(json => console.log(json));

Retrieve Projects

Get all the projects you have access to.

const fetch = require("node-fetch");

const apiKey = "MY_API_KEY"; // replace with your own API key

fetch(`https://www.freelancer.com/api/projects/0.1/projects?compact=true`, {
    headers: {
        "Freelancer-Developer-OAuth-Client-Id": apiKey
    }
})
.then(response => response.json())
.then(json => console.log(json));

Create a Project

Create a new project.

const fetch = require("node-fetch");

const apiKey = "MY_API_KEY"; // replace with your own API key

const payload = JSON.stringify({
    "title": "New Project Title",
    "description": "New Project Description",
    "currency": "USD",
    "budget": {
        "minimum": "10",
        "maximum": "100"
    },
    "location": "Los Angeles",
    "jobs": [
        {
            "id": "5",
            "expertise_id": "111",
            "description": "Job description",
            "budget": {
                "minimum": "10",
                "maximum": "100"
            },
            "priority": "10"
        }
    ]
});

fetch(`https://www.freelancer.com/api/projects/0.1/projects`, {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "Freelancer-Developer-OAuth-Client-Id": apiKey
    },
    body: payload
})
.then(response => response.json())
.then(json => console.log(json));

These JavaScript examples should give you a good starting point for integrating your application or website with Freelancer.com API.

Conclusion

Freelancer.com API offers a powerful and flexible way to access data and create new projects. By using their public API, you can easily integrate with Freelancer.com and take advantage of all they have to offer. We hope this guide has helped you get started with Freelancer.com API and provided some useful JavaScript examples for your application or website. Happy coding!

Related APIs in Jobs