Giter Club home page Giter Club logo

python-upwork's Introduction

Python bindings for Upwork API (OAuth1)

License PyPI Version GitHub release Build Status

Upwork API

This project provides a set of resources of Upwork API from http://developers.upwork.com based on OAuth 1.0a.

Features

These are the supported API resources:

  • My Info
  • Custom Payments
  • Hiring
  • Job and Freelancer Profile
  • Search Jobs and Freelancers
  • Organization
  • Messages
  • Time and Financial Reporting
  • Metadata
  • Snapshot
  • Team
  • Workd Diary
  • Activities

License

Copyright 2020 Upwork Corporation. All Rights Reserved.

python-upwork is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SLA

The usage of this API is ruled by the Terms of Use at:

https://developers.upwork.com/api-tos.html

Requirements

To integrate this library you need to have:

  • Python 3.8+
  • requests_oauthlib >= 1.3.0

Installation

pip3 install python-upwork

All the dependencies will be automatically installed as well.

Usage

Follow instructions from the Installation section.

Run myapp.py and follow the instructions, or open myapp.py and type the consumer_key and consumer_secret that you previously got from the API Center. That's all. Run your app as python myapp.py and have fun.'

python-upwork's People

Contributors

ak4nv avatar brendancol avatar kipanshi avatar michael-yin avatar mnovozhylov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-upwork's Issues

get_by_freelancer_limited returns "Verification of signature failed"

Here's the code:

reports.time.Gds(self.client).get_by_freelancer_limited(
 UPWORK_FREELANCER_ID,
 { "tq": "SELECT worked_on,  assignment_team_id, assignment_ref, hours, task, memo" }
)

I've verified that client credentials are ok, the UPWORK_FREELANCER_ID is my Upwork username, other endpoints like Auth work, and running the same request with Postman does return the expected result.

Why get_job_profile method get 403 error on some query

I found out when I want to get some job profile, sometime I got 403 error message.

Here is one example.

2015-06-23 20:33:12 DEBUG    HTTP403ForbiddenError: https://www.upwork.com/api/profiles/v1/jobs/~01d79d1f56f49fcea6.json, 403, Code 403: Profile ~01d79d1f56f49fcea6 is disabled, HTTPHeaderDict({'x-upwork-error-code': '403', 'transfer-encoding': 'chunked', 'x-odesk-error-message': 'Profile ~01d79d1f56f49fcea6 is disabled', 'expires': 'Fri, 13 Oct 2000 05:00:00 GMT', 'vary': 'Cookie,Accept-Encoding', 'x-odesk-error-code': '403', 'server': 'cloudflare-nginx', 'last-modified': 'Tue, 23 Jun 2015 12:33:12 GMT', 'connection': 'keep-alive', 'x-upwork-error-message': 'Profile ~01d79d1f56f49fcea6 is disabled', 'pragma': 'no-cache', 'cache-control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'date': 'Tue, 23 Jun 2015 12:33:12 GMT', 'cf-ray': '1fb03851ea1d1e83-SJC', 'content-type': 'application/json', 'set-cookie': '__cfduid=d740324609cc573b26b091488e62364f21435062791; expires=Wed, 22-Jun-16 12:33:11 GMT; path=/; domain=.upwork.com; HttpOnly'}), None

When I check this job by visiting url https://www.upwork.com/c/jobs/~01d79d1f56f49fcea6, I can indeed see the job profile. How should I do to fix this problem?

Milestones Order Not Correct

I am using the upwork api to make an offer. I notice the milestones are not getting ordered properly:

>>> milestones

[{'due_date': '08-15-2017', 'deposit_amount': 60, 'milestone_description': '1. Basic English Exam (mcq), Grammar Exam (mcq), Early Math Exam (mcq), and Arithmetic Exam (mcq) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-16-2017', 'deposit_amount': 40, 'milestone_description': '2. Algebra Exam (mcq) and Geometry Exam (mcq) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-17-2017', 'deposit_amount': 80, 'milestone_description': '3. Introductory CS Exam (mcq), Command Line Exam (mcq), Source Control Exam (mcq), and Internet Exam (mcq) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-18-2017', 'deposit_amount': 30, 'milestone_description': '4. English Exam (mcq) and Idioms exam (mcq) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-19-2017', 'deposit_amount': 60, 'milestone_description': '5. Python Exam (mcq) and SQL Exam (mcq) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-20-2017', 'deposit_amount': 45, 'milestone_description': '6. HTML/CSS Exam (mcq) and Javascript Exam (mcq) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-21-2017', 'deposit_amount': 100, 'milestone_description': '7. Django Exam (mcq, includes autograded coding sample) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-22-2017', 'deposit_amount': 75, 'milestone_description': '8. AngularJS Exam (mcq, includes autograded coding sample) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-23-2017', 'deposit_amount': 50, 'milestone_description': '9. Worker Scraper Exam (mcq, includes autograded coding sample) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-24-2017', 'deposit_amount': 50, 'milestone_description': '10. Wordpress Exam (mcq) on goo.gl/btyoOM (moodle)'}]

>>> 

>>> 

>>> client.offers.send_client_offer('Congratulations, you have been offered the job WEBDEVELOPER at Learning Dollars Inc. ' + datetime.strftime(datetime.now(), '%m-%d-%Y'), 'fixed-price', TOTALPRICE, 'Please accept this job to get started at Learning Dollars Inc.', contractor_username='dasugovinda', context=CONTEXT['WEBDEVELOPER'], milestones=milestones, close_on_accept=0)

PRODUCES the attached file

Please let me know the solution.

screen shot 2016-08-15 at 8 21 22 pm

Job search result not latest

Please pardon me If this question already asked.

I like to get the latest jobs using Python-Upwork.

https://developers.upwork.com/?lang=python#jobs

And I found that result are not latest and the latest result is one hour ago. Why this behaviour? Or did I missing something?

How to use upwork client with Django?

HI

I'm developing the application with Django framework. As you know that Django is not keeping the client instance across request. I can't find the way to make it work.

def access(request):
    client = upwork.Client(public_key, secret_key)
    url = client.auth.get_authorize_url()
    return HttpResponseRedirect(url)
def authorize(request):
    oauth_verifier = request.GET.get('oauth_verifier')
    oauth_access_token, oauth_access_token_secret = \
        client.auth.get_access_token(oauth_verifier)

Though this is not working because again I need to call the get_authorize_url. I don't like this behaviour because I wanted to use client instance wherever in the Django environment. Is there any way I can make it work with across request. Like Reddit Praw they have multi instance.

Please point me in the right direction...

Usage of .iteritems() doesn't support for python3

My project has been migrated to Python3 lately and I figured out that the newest code didn't update the dictionary method iteritems.
I found this error the method offers.send_client_offer.
Can somebody take a look?

Page size

Why is the page size restricted to 100, while the FAQ (https://developers.upwork.com/api-faq.html#) states:

Q: Are search results limited to a specific number of results?
A: Yes, Freelancers and Jobs search results are limited to 5,000 results.

Am I missing something or is the FAQ outdated? I think 100 results is rather limited.

Thanks,

Christian

Multiple profiles in get_providers not working

If I try to get multiple providers in one call of get_provider, e.g.:

client.provider.get_provider(provider_ciphertext = ('~0120bf8d6066507040', '~0120bf8d6066507040'))

I get the error:

HTTP401UnauthorizedError: HTTP Error 401: Code 401: Verification of signature failed.

I have tried at multiple ways of formatting a tuple or list of provider ciphertexts and none of them work. Examining the code implementation, the error seems to result because:

'providers/~0120bf8d6066507040;~0120bf8d6066507040'

is not a valid url

SyntaxError: invalid syntax

Collecting python-upwork
Downloading python-upwork-1.2.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\myuser\AppData\Local\Temp\pip-build-bq1kuaer\python-upwork\setup.py", line 35
print 'Updating upwork/__init__.py to version "{0}"'.format(version)
^
SyntaxError: invalid syntax

Python3 is not supported

Python3 is not supported

pip install python-upwork
Collecting python-upwork
  Downloading python-upwork-1.2.3.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-nz6qxrn7/python-upwork/setup.py", line 35
        print 'Updating ``upwork/__init__.py`` to version "{0}"'.format(version)
                                                               ^
    SyntaxError: invalid syntax
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-nz6qxrn7/python-upwork/

get_authorize_url() trouble

During the initial oauth dance, I'm experience the following trouble (Python3) (python-upwork=1.3)

The code snippet below is returning a auth_url without an oauth_token url parameter

Code

client = upwork.Client(PUBLIC_KEY, SECRET_KEY)
auth_url = client.auth.get_authorize_url()
webbrowser.open(url=auth_url, autoraise=True, new=2)
print('Go to the mentioned URL : {}'.format(auth_url))
verifier = input('Enter Verifier: ')

Result

print(auth_url)
>>> https://....?**oauth_token=None**

My upwork app key has freelancer search / public profiles permission and ENABLED status.

Any idea whats going on here? I just looking to be able to do freelance queries.

ca_certs_locater.get() not working

Hey,

I'm trying to get the example working, but I'm running into a problem with ca_cert_locater. The error I get:

File "retrieve_jobs.py", line 31, in
client = create_client()
File "retrieve_jobs.py", line 8, in create_client
client = upwork.Client(public_key, secret_key)
File "/Users/csdenboer/Projects/UWJobRetriever/lib/python2.7/site-packages/upwork/client.py", line 118, in init
ca_certs=ca_certs_locater.get(),
File "/Users/csdenboer/Projects/UWJobRetriever/lib/python2.7/site-packages/ca_certs_locater/init.py", line 36, in get
raise ImportError()
ImportError

The following list of pip packages is installed:

  • httplib2 (0.9)
  • httplib2.ca-certs-locater (0.2.0)
  • httplib2.system-ca-certs-locater (0.1.2)
  • oauth2 (1.5.211)
  • pbr (1.8.1)
  • pip (7.1.2)
  • python-upwork (1.1)
  • setuptools (18.2)
  • urllib3 (1.10)
  • wheel (0.24.0)

I also tried replacing cacerts.txt with the cacert.pem provided in http://stackoverflow.com/questions/9270195/python-ssl-issue-with-oauth2, also without success. Anyone knows how I can solve this?

Upwork example code throws timeout and

I've been trying to work with this library for several days now, in both python 2 and 3 (it's not even a little functional in python 3, you should remove that note).

I followed the Upwork API Reference here: https://developers.upwork.com/?lang=python#getting-started_libraries-and-tools.

Specifically:

$ mkdir upwork_project
$ cd upwork_project
$ virtualenv --no-site-packages ve
$ git clone https://github.com/upwork/python-upwork.git
$ cd python-upwork
$ source ../ve/bin/activate
$ python setup.py install

The instructions say the example code is in a folder called 'examples' which doesn't exist; instead I found desktop_app.py inside the 'upwork' folder. After running:

$python desktop_app.py

amd entering my key and secret, I am able to authenticate and retrieve the verification code, and then I get this:

Retrieving keys.... 
OK
My info
Exception at GET https://www.upwork.com/api/auth/v1/info.json
Traceback (most recent call last):
  File "desktop_app.py", line 60, in <module>
    raise e
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.VerifiedHTTPSConnection object at 0x7f30086312d0>, 'Connection to www.upwork.com timed out. (connect timeout=0.5)')

I tried modifying the desktop_app.py code to set the TIMEOUT property on the client, but this is apparently a different timeout. So Instead I had to modify client.py to change the HARDCODED timeoute from 0.5 to 20, which allows me to get past the timeout. However I then get:

Retrieving keys.... 
OK
My info
[REDACTED]
Team rooms:
Exception at GET https://www.upwork.com/api/auth/v1/info.json
Traceback (most recent call last):
  File "desktop_app.py", line 60, in <module>
    raise e
AttributeError: 'Client' object has no attribute 'team'

That looks like a bigger problem than I feel like troubleshooting, so figured I'd let you guys know.

Tested in python 2.7.16 on ubuntu

get_job_profile returns 401

Try following code:

import upwork
c = upwork.Client(PUBLIC_KEY, SECRET_KEY, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
c.job.get_job_profile('~01039b34ec50422991')

get_job_profile call fails with following exception:

Traceback (most recent call last):
  File "test.py", line 17, in <module>
    c.job.get_job_profile('~01039b34ec50422991')
  File ".venv/lib/python3.6/site-packages/upwork/routers/job.py", line 45, in get_job_profile
    result = self.get(url)
  File ".venv/lib/python3.6/site-packages/upwork/namespaces.py", line 34, in get
    return self.client.get(self.full_url(url), data)
  File ".venv/lib/python3.6/site-packages/upwork/client.py", line 177, in get
    return self.read(url, data, method='GET', fmt=self.fmt)
  File ".venv/lib/python3.6/site-packages/upwork/client.py", line 294, in read
    raise_http_error(url, response)
  File ".venv/lib/python3.6/site-packages/upwork/http.py", line 41, in raise_http_error
    headers, None)
upwork.exceptions.HTTP401UnauthorizedError: HTTP Error 401: Code 401: Verification of signature failed.

The issue exists only with urllib3==1.25+. With urllib3==1.24.2 it works ok. Looks like the issue is caused by the the way urllib3==1.25+ treats URLs containing ~ - this symbol gets encoded to %7E.

Activities router get_list method doesn't allow pagination

Hey guys,

I'm trying to fetch all activities code by company using:

from upwork.routers.activities import team
team.Api(client).get_list()

but it only accepts company and team parameters. As I have much more than 1000 activities, I can't get the remaining codes as I can't provide pagination params to the method.

May you please take a look at it?

Thanks!

How to defined the number of results to retrieve

I'm doing the following with the latest version, 2.0.1:

params = {
    "q": term, 
    "page_size": 100
}
params = urllib.parse.urlencode(params, quote_via=urllib.parse.quote)
results = search.Api(client).find(params)

But I'm not really getting more than 10 results per call. How can I specify the number of results to get as well as the pagination?

Thanks

Yosemite. Difficult to locate ca_cert

Hi,

I am having an issue to locate ca_cert on Mac Yosemite. I followed all steps of installation with success. But when I try to
upwork.Client(key, secret)

it returns an error

Traceback (most recent call last):
File "/Users/cgirabawe/SideProjects/upwork-project/smartUpwork.py", line 14, in
smartuw = SmartUpwork(credentials.key[0], credentials.secret[0])
File "/Users/cgirabawe/SideProjects/upwork-project/smartUpwork.py", line 7, in init
client = upwork.Client(key, secret)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/upwork/client.py", line 118, in init
ca_certs=ca_certs_locater.get(),
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ca_certs_locater/init.py", line 36, in get
raise ImportError()
ImportError

I am new to Mac and I think you guys you can help me to turn around the issue.

Thank you

ImportError: cannot import name 'auth'

I tried to launch example but I got this error

Traceback (most recent call last):
File "myapp.py", line 3, in
from upwork.routers import auth
ImportError: cannot import name 'auth'

client.epoint is modified by Gds class but not by Api

When calling the Gds class in the reports module the entry point is updated to "gds", however when subsequently calling an Api class it is not set back to "api". This results in the following error:

>>>from upwork.routers.hr import engagements
>>>from upwork.routers.reports.finance import earnings, billings
>>> e = engagements.Api(client).get_list("{}")
<Response [200]>
>>> r = earnings.Gds(client).get_by_freelancer('test', {'tq': quote('SELECT amount WHERE worked_on "2019-06-01" AND worked_on <= "2019-06-02"')})
<Response [200]>
>>> e = engagements.Api(client).get_list("{}")
<Response [500]>
>>> engagements.Api(client).get_list("{}")
<Response [500]>
{'version': '0.6', 'status': 'error', 'errors': [{'reason': 'other', 'message': 'Wrong URL requested'}]}
>>> client.epoint = 'api'
>>> e = engagements.Api(client).get_list("{}")
<Response [200]>
>>>

Here is an example of responsible code in the upwork.routers.reports.finanance.earnings module:

class Gds:
    """ """

    client = None
    entry_point = "gds"

    def __init__(self, client):
        self.client = client
        self.client.epoint = self.entry_point

Api class does not set this back to "api":

class Api:
    """ """

    client = None

    def __init__(self, client):
        self.client = client

Error while instellation

Collecting python_upwork
Using cached https://files.pythonhosted.org/packages/37/7a/d8ab8d6611ed87e56e8df9888fe2dedff70fe2ffabc962024a03cc6bd474/python-upwork-1.2.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-m13o8nux/python-upwork/setup.py", line 35
print 'Updating upwork/__init__.py to version "{0}"'.format(version)
^
SyntaxError: invalid syntax

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-m13o8nux/python-upwork/

Python 3 is not supported

Have you thought about how you will support Python 3?

I may have some time to contribute to this, but I want to check if you've done anything on this task first.

KeyError: 'consumer_key' on Linux with old and latest python installed, on windows all fine.

Traceback (most recent call last):
File "best-upwork-script.py", line 15, in
config = upwork.Config(
File "/usr/local/lib/python3.8/dist-packages/upwork/config.py", line 22, in init
config["consumer_key"],
KeyError: 'consumer_key'

so by this i cant bring up my script to work on linux, used 3.8 python to 3.10.5 python from 3rd party repos
no luck, but on windows with 3.10.4 and 3.10.5 latest stable all works like a charm
`

upwork config & token

from upwork.routers.jobs import search
import requests
import upwork
import time


token = {
    "access_token": "xxxxxxxxxxxxxxxxx",
    "expires_at": xxxxxxxx,
    "expires_in": xxxxxxx,
    "refresh_token": "xxxxxxxxxxxxxxxxxxxxxx",
    "token_type": "Bearer",
}
#
config = upwork.Config(
    {
        "client_id": "xxxxxxxxxxxxxxxxxxxxxxxx",
        "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "token": token
    }
)
client = upwork.Client(config)
variable = search.Api(client).find(params)
print(variable)

nothing major have changed from 3.8 version

/usr/local/lib/python3.8/dist-packages/upwork/config.py

Invalid Syntax Error in setup.py - line 35

Hi:

I'm attempting to install python-upwork, and the pip install fails at line 35 of settings.py. The syntax error has to do with the command - print 'Updating upwork/__init__.py to version "{0}"'.format(version)

If you need any more info, contact me.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.