Support for Etsy API v2 #1

Merged
17 commits merged into from Jan 27, 2011

Conversation

Projects
None yet
2 participants
@msabramo
Contributor

msabramo commented Jan 19, 2011

Hi Dan,

Here are changes that I made to etsy-python in order to make it work with Etsy API v2.

I am using this for a Django-powered site that creates Etsy listings from a CSV file. I wrote this site for my sister so that she could save time. As a result, this has been tested but only with a fairly limited set of functionality, primary the createListing and uploadListingImage calls. I am using Python 2.7 -- not sure if anything 2.7-specific crept in there. I did a quick test with Python 2.5 and I was able to create a listing and upload an image to the listing in the Sandbox so that's a good sign.

I haven't tested extensively with different character encodings for titles and descriptions. Actually, my sister was having problems because she was using Windows and so her data had character code \x92 in it, which is a right single quote/apostrophe, U+2019 (8217), in the Windows-1252 character encoding. The Etsy API was choking on this. I tried reencoding the text to UTF-8, but it seems like the Etsy API only allows a limited set of characters in titles and descriptions. So maybe this isn't an issue if Etsy doesn't support Unicode, but you would know better than me.

These changes require the oauth2 package for OAuth support -- http://pypi.python.org/pypi/oauth2/ -- personally, I am using oauth2-1.2.0-py2.7.egg -- I've made oauth2 an optional dependency (i.e.: it's in the "extras_require" section of setup.py) though, since you should in theory be able to use etsy-python just fine without installing oauth2 if you're only doing read-only, unauthenticated operations. Personally, I'm doing pretty much all authenticated operations so I haven't tested much without oauth2.

Thanks for making etsy-python available. I hope that these changes are useful and help to revive etsy-python so that Python developers have a nice API for accessing Etsy.

Regards,

Marc Abramowitz
http://marc-abramowitz.com/

msabramo and others added some commits Dec 22, 2010

Have basic support for Etsy V2 API working, including OAuth.
I was able to add a listing using createListing.
- setup_requires=['simplejson >= 2.0'],
+    install_requires=['simplejson >= 2.0'],

so that simplejson gets installed along with etsy-python (rather than simply downloaded). See http://peak.telecommunity.com/DevCenter/setuptools#new-and-changed-setup-keywords
Move EtsyOAuthClient from etsy/_v2.py to etsy/oauth.py. This way clients
that are read-only can opt to not import etsy.oauth and not need oauth2
installed.
Marc Abramowitz
Allow passing args to get_signin_url and get_request_token. This is
needed especially in order to let the client pass in an oauth_callback
when calling get_signin_url.
EtsyOAuthToken = oauth.Token -- so that clients can use EtsyOAuthToken
and not have to import or know about the oauth2 package.
One line hack to make the type checking not complain about the
"includes" parameter for associations, since this parameter isn't
listed in the method table.
Change file check from isinstance(value, file) to hasattr(value, 'rea…
…d') so that file-like objects are handled.

-                if isinstance(value, file):
-                    file_object = value
-                    files.append((name, file_object.name, file_object.read()))
+                if hasattr(value, 'read'):
+                    files.append((name, value.name, value.read()))
Benjamin Trott
Fixed get_access_token.
Use the proper form in python-oauth2 for setting the verifier
value for use in getting the access token & secret.
@mcfunley

This comment has been minimized.

Show comment
Hide comment
@mcfunley

mcfunley Jan 19, 2011

Owner

Looks good at first blush, I'll get it merged and get the pypi package updated ASAP

Owner

mcfunley commented Jan 19, 2011

Looks good at first blush, I'll get it merged and get the pypi package updated ASAP

@mcfunley

This comment has been minimized.

Show comment
Hide comment
@mcfunley

mcfunley Jan 27, 2011

Owner

merged

Owner

mcfunley commented Jan 27, 2011

merged

@msabramo

This comment has been minimized.

Show comment
Hide comment
@msabramo

msabramo Jan 28, 2011

Contributor

Would you mind giving me a quick little shout-out in the readme? "Marc Abramowitz (http://marc-abramowitz.com)". I see you mentioned someone else named Ben Dayan, but it looks like you're using my code as well.

Contributor

msabramo commented Jan 28, 2011

Would you mind giving me a quick little shout-out in the readme? "Marc Abramowitz (http://marc-abramowitz.com)". I see you mentioned someone else named Ben Dayan, but it looks like you're using my code as well.

@msabramo

This comment has been minimized.

Show comment
Hide comment
@msabramo

msabramo Jan 28, 2011

Contributor

It looks like the readme needs updating for other things too:

Draft - v2 API support not implemented yet.

There are currently two versions of the Etsy API, v1 and v2. This library works with both versions. The
basic interface to either API is the same, although many of the methods are different. In order to use the
v2 API,
Contributor

msabramo commented Jan 28, 2011

It looks like the readme needs updating for other things too:

Draft - v2 API support not implemented yet.

There are currently two versions of the Etsy API, v1 and v2. This library works with both versions. The
basic interface to either API is the same, although many of the methods are different. In order to use the
v2 API,
@mcfunley

This comment has been minimized.

Show comment
Hide comment
@mcfunley

mcfunley Jan 28, 2011

Owner

My bad, that was someone who emailed me a completely different patch apparently. Coming up.

Owner

mcfunley commented Jan 28, 2011

My bad, that was someone who emailed me a completely different patch apparently. Coming up.

@msabramo

This comment has been minimized.

Show comment
Hide comment
@msabramo

msabramo Jan 29, 2011

Contributor

Thanks for updating the readme! Is it possible to update the pypi page? No big deal if it won't let you update without pushing a new version or something like that.

Contributor

msabramo commented Jan 29, 2011

Thanks for updating the readme! Is it possible to update the pypi page? No big deal if it won't let you update without pushing a new version or something like that.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment