mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-21 22:06:53 +08:00
'enable_api = True' in config file. You should not enable the API on production sites as this code is brand new and may contain serious bugs and security flaws! Implemented: * Display libraries * Display library info * Display library contents * Display library content info * Create library folders * Upload datasets to a library from a server directory or with a path paste. * Basic example scripts in scripts/api/ Framework changes that were made to support this: * API Key interface in User Preferences. * New api_keys database table for storing users' API Keys. * New API-specific route mapper in webapp. * API controllers in galaxy.web.api * Return handling in reused library_common methods. * expose_api decorator for API controller methods validates key and ensures valid JSON format. * UniverseWebTransaction renamed to GalaxyWebTransaction and subclassed for GalaxyWebUITransaction and GalaxyWebAPITransaction. Things that need to be done next: * Documentation! * Refactor reused code from library_common and other controllers into an even-more-generic location and format. The main changes are that the Web UI returns redirects and rendered templates, whereas the API returns various HTTP status codes and JSON. * Implement more functionality. * The request and response format should be considered alpha and are subject to change. They will be standardized as the API matures. Hints to get started can be found in scripts/api/README
This is not documentation. These are hints and examples to get you started until the documentation is written. Set these options in universe_wsgi.ini and start the server: enable_api = True admin_users = you@example.org library_import_dir = /path/to/some/directory In the directory you specified for 'library_import_dir', create some subdirectories, and put (or symlink) files to import into Galaxy into those subdirectories. In Galaxy, create an account that matches the address you put in 'admin_users', then browse to that user's preferences and generate a new API Key. Copy the key to your clipboard. Create a new library (doing this via the API is not yet implemented). Then take your API Key and use the scripts in scripts/api/ to do things: % ./display.py my_key http://localhost:4096/api/libraries Collection Members ------------------ /api/libraries/f3f73e481f432006 name: api_test id: f3f73e481f432006 % ./display.py my_key http://localhost:4096/api/libraries/f3f73e481f432006 Member Information ------------------ synopsys: None contents_url: /api/libraries/f3f73e481f432006/contents description: API Test Library name: api_test % ./display.py my_key http://localhost:4096/api/libraries/f3f73e481f432006/contents Collection Members ------------------ /api/libraries/f3f73e481f432006/contents/28202595c0d2591f61ddda595d2c3670 name: / type: folder id: 28202595c0d2591f61ddda595d2c3670 % ./library_create_folder.py my_key http://localhost:4096/api/libraries/f3f73e481f432006/contents 28202595c0d2591f61ddda595d2c3670 api_test_folder1 'API Test Folder 1' Response -------- /api/libraries/f3f73e481f432006/contents/28202595c0d2591fa4f9089d2303fd89 name: api_test_folder1 id: 28202595c0d2591fa4f9089d2303fd89 % ./library_upload_from_import_dir.py my_key http://localhost:4096/api/libraries/f3f73e481f432006/contents 28202595c0d2591fa4f9089d2303fd89 bed bed hg19 Response -------- /api/libraries/f3f73e481f432006/contents/e9ef7fdb2db87d7b name: 2.bed id: e9ef7fdb2db87d7b /api/libraries/f3f73e481f432006/contents/3b7f6a31f80a5018 name: 3.bed id: 3b7f6a31f80a5018 % ./display.py my_key http://localhost:4096/api/libraries/f3f73e481f432006/contents Collection Members ------------------ /api/libraries/f3f73e481f432006/contents/28202595c0d2591f61ddda595d2c3670 name: / type: folder id: 28202595c0d2591f61ddda595d2c3670 /api/libraries/f3f73e481f432006/contents/28202595c0d2591fa4f9089d2303fd89 name: /api_test_folder1 type: folder id: 28202595c0d2591fa4f9089d2303fd89 /api/libraries/f3f73e481f432006/contents/e9ef7fdb2db87d7b name: /api_test_folder1/2.bed type: file id: e9ef7fdb2db87d7b /api/libraries/f3f73e481f432006/contents/3b7f6a31f80a5018 name: /api_test_folder1/3.bed type: file id: 3b7f6a31f80a5018 % ./display.py my_key http://localhost:4096/api/libraries/f3f73e481f432006/contents/e9ef7fdb2db87d7b Member Information ------------------ misc_blurb: 68 regions metadata_endCol: 3 data_type: bed metadata_columns: 6 metadata_nameCol: 4 uploaded_by: nate@... metadata_strandCol: 6 name: 2.bed genome_build: hg19 metadata_comment_lines: None metadata_startCol: 2 metadata_chromCol: 1 file_size: 4272 metadata_data_lines: 68 message: metadata_dbkey: hg19 misc_info: uploaded bed file date_uploaded: 2010-06-22T17:01:51.266119 metadata_column_types: str, int, int, str, int, str Other parameters are valid when uploading, they are the same parameters as are used in the web form, like 'link_data_only' and etc. The request and response format should be considered alpha and are subject to change.