E*TRADE Developer Platform - Cdn.etrade

Transcription

E*TRADE Developer PlatformDeveloper Guide and API ReferenceDecember 17, 2012API Version: v0

ContentsGetting Started . 5Introduction. 6Architecture . 6Authorization . 6Agreements . 7Support & Community . 8The E*TRADE API. 9About the API. 9API Syntax .10API Documentation .11Terminology .12Next Steps .13Developer Guide . 14Authorizing the Application .15Overview.15The User Experience .17Using OAuth Credentials .19The OAuth API Module .21The Sandbox Environment .22Overview.22Accessing the Sandbox .22About Rate Limits .24Overview.24Limits .24Requests for Multiple Items.24The Get Rate Limits API .25About Notifications.26Alerts .26Notifications .26Streaming Updates .26The Streaming API .27Introduction .27Notifications .27Using Comet .29Sample code .30REST API Reference . 34Authorization .35Get Request Token .35Authorize Application .37Get Access Token .39Renew Access Token .41Revoke Access Token .43Accounts .45

List Accounts .45Get Account Balance .48Get Account Positions.53List Alerts .62Read Alert.68Delete Alert .71Get Transaction History .73Get Transaction Details .87Market .91Look Up Product .91Get Quote .94Get Option Chains .115Get Option Expire Dates .121Orders .124List Orders .124Preview Equity Order .142Place Equity Order .149Preview Equity Order Change .157Place Equity Order Change .163Preview Option Order .170Place Option Order .178Preview Option Order Change .187Place Option Order Change .194Cancel Order .202Rate Limits .205Get Rate Limits .205Notifications .208Get Notifications .208Error Handling .212Overview.212HTTP Status Codes .214Account Module Error Messages .215Market Module Error Messages .216Order Module Error Messages .217Notification Error Messages .220Code Resources . 221Tutorial: Start Developing in Java .222Introduction .222Requirements .222Step 1: OAuth Authorization.222Step 2: Retrieve a list of accounts .224What's next? .225E*TRADE SDK Guides .226Using the Java SDK .226Using the PHP SDK .229Using the VC SDK .238Code Snippets: Accounts .259

Initialize Accounts Client .259List Accounts .259Get Account Balance .259Get Account Positions.260List Alerts .260Read Alert.260Delete Alert .261Code Snippets: Market .262Initialize Market Client .262Get Quote .262Look Up Product .263Get Option Expire Dates .263Get Option Chains .263Code Snippets: Order .265Initialize Order Client.265List Orders .265Preview Equity Order .266Place Equity Order .266Preview Equity Order Change .267Place Equity Order Change .268Preview Option Order .269Place Option Order .270Preview Option Order Change .271Place Option Order Change .272Cancel Order .273

Getting StartedThis section provides a brief overview of the E*TRADE Developer Platform and offerssuggestions on how to start learning and using the API.E*TRADE Developer Platform5Getting Started

IntroductionThe E*TRADE Developer Platform enables E*TRADE customers and developers to create theirown investment applications that leverage E*TRADE's extensive market data offerings, orderrouting capabilities, and other services.The platform's API also allows E*TRADE customers who currently use a third-party tradingplatform to view E*TRADE account and market information and place trade orders directly toE*TRADE from that platform.Using the E*TRADE Developer Platform, a client application can: Authenticate E*TRADE customersDirectly manage trading: place orders, modify or cancel orders, and check order statusReview specific information for an account, such as balances and current positionsRetrieve price and other information about an index, stock, or optionReceive system messages from E*TRADEArchitectureThe E*TRADE Developer Platform provides most of its services via a REST API. Most of theAPI features are accessed via simple HTTP GET requests. Requests that require detailedinput, such as an order to buy or sell stock, use an HTTP POST request, with the parametersincluded as either XML or JSON data. The HTTP DELETE request is also used, with one API,to delete messages after they have been read.Although most of the platform uses a RESTful request-response model, a streaming API is alsoprovided, so that an application can receive timely "push" notifications of order status changes.AuthorizationThe E*TRADE REST API uses the OAuth protocol to authorize every service request. Inpractice, this means that your application must enable users to log in to their E*TRADE accountand click a consent button to grant access for each session. For your application to do this,even for testing purposes, requires an OAuth consumer key - a code that uniquely identifies theapplication (i.e., the service consumer) and its developer.Consumer keysWe support two levels of consumer key. An individual key is tied to a single user ID, and allowsaccess for only that user. This is appropriate for developing applications for personal use, or forthe early stages of a larger development effort. A vendor key, on the other hand, permitsaccess by multiple users and is appropriate for applications that may be widely distributed.E*TRADE Developer Platform6Getting Started

Note that separate keys are required for accessing "sandbox" data (used for development andtesting purposes) versus actual production data. For this reason, a typical developer has atleast two consumer keys.Requesting keysTo request a key, you must have an E*TRADE account. (You will also need the account so thatyou can log in and use your application.) It can be a personal, professional, or corporateaccount. If you don't have one, you can quickly set one up online at http://www.etrade.com.For development purposes, it is not necessary to fund the account, but to do any actual tradingwill require funds.When you are logged in to your account, request a consumer key via a secure message on thispage: https://us.etrade.com/e/t/accounts/sccreatemsg. Select the subject "Technical Issue" andthe topic "E*TRADE API". Be sure to: State that you are requesting a consumer keyExplain the type of application you are developingSpecify whether you want an individual or vendor keyYou may also want to request that your user account be approved as a non-funded account, sothat you're not required to have funds in the account to keep it open.Within a few business days, a sandbox consumer key will be sent back to you by securemessage, along with a Developer Agreement which you will need to review and sign. Whenwe've received your agreement and processed your request, we'll issue you a productionconsumer key.When you get the key, you will be notified of its scheduled expiration date - typically, two yearsfrom its creation date.Note that if you are assigned an individual key, rather than a vendor key, it will only work withyour E*TRADE account. Attempting to use an individual key with a different user account willresult in an error.AgreementsDevelopers and users are asked to sign several types of agreements: API Agreement - As a developer, you are asked to sign an API agreement before youwill be issued a consumer key for production data. As mentioned earlier, requesting akey requires that you log in to your E*TRADE account and send a secure message.Authorization - As a user, whenever the application starts a session with the E*TRADEplatform, you must log in to your E*TRADE account and agree to an authorizationrequest.E*TRADE Developer Platform7Getting Started

RTQ Agreement - As a user, you must sign the Real-Time Quote Agreement before youcan access data with the quote API. You can do this at http://www.etrade.com.Extended-hours Agreement - As a user, you must sign the Extended-Hours Discl

Dec 08, 2016 · After the host (etws.etrade.com) comes the API module (e.g., oauth, account, market, or order), a standard path element /rest/ , and the API endpoint ( quote in this example). There may beFile Size: 2MB