draftbit / twitter-lite

A tiny, full-featured, flexible client / server library for the Twitter API
https://npm.im/twitter-lite
MIT License
794 stars 95 forks source link

Document the subdomain constructor property #7

Open dandv opened 6 years ago

dandv commented 6 years ago

Haven't seen this in the other Twitter libraries. Presumably it would help with issues like https://github.com/ttezel/twit/issues/415, though it's probably better to abstract the resource subdomains from the user.

dylanirlbeck commented 4 years ago

@dandv It's been a while for this issue, but I think you make an important point. What is the best way to handle Twitter endpoints that don't start with api.twitter.com (for example, publish.twitter.com). Right now we just pass in a string to the constructor like this:

const client = new Twitter({
  subdomain: "api", // this could be "publish", for example
  consumer_key: "abc", // from Twitter.
  consumer_secret: "def", // from Twitter.
  access_token_key: "uvw", // from your User (oauth_token)
  access_token_secret: "xyz" // from your User (oauth_token_secret)
});

When you say "it's probably better to abstract the resource subdomains from the user", what do you have in mind? Would we want a full-fledged object that corresponds to each subdomain like this?

// instead of
client.get("statuses/show", {...})

// we have
client.statuses.show({...})

Let me know what you had in mind!