apyclient.Python API Ŭ¶óÀ̾ðÆ® | |
Áö±Ý ´Ù¿î·Îµå |
apyclient. ¼øÀ§ ¹× ¿ä¾à
±¤°í
- ƯÇã:
- BSD License
- °¡°Ý:
- FREE
- °Ô½ÃÀÚ À̸§:
- Aaron Madison
- °Ô½ÃÀÚ À¥»çÀÌÆ®:
- https://github.com/madisona/
apyclient. ű×
apyclient. ¼³¸í
ApyClient´Â »ç¿ëÀÚ Á¤ÀÇ°¡ °¡´ÉÇÑ Way·Î Ŭ¶óÀ̾ðÆ® API¸¦ ½±°Ô ¸¸µé ¼öÀÖ´Â ÆÄÀ̽㠸ðµâÀÔ´Ï´Ù .InstallationOnly ¿ä±¸ »çÇ×Àº Python 2.6 ÀÌ»óÀÔ´Ï´Ù. Å×½ºÆ®°¡ ÇÊ¿äÇÑ 'mock'package.pip ¼³Ä¡ apyclientusageyou Ŭ¶óÀ̾ðÆ® API Ŭ·¡½º¸¦ ½±°Ô ¸¸µé ¼ö ÀÖ½À´Ï´Ù. API Ŭ·¡½ºÀÇ À¯ÀÏÇÑ ¿ä±¸ »çÇ×Àº "host_name"¼Ó¼ºÀÌ ¼±¾ðµÇ¾î¾ßÇÑ´Ù´Â °ÍÀÔ´Ï´Ù. API´Â request.class myApiclient (object)¸¦ ºôµå ÇÒ ¶§ ¿£µå Æ÷ÀÎÆ®¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ¾Õ¿¡ ºÙÀÌ°ÔÇÕ´Ï´Ù. host_name = "http://www.example.com"@api_request ( "/ api-endpoint /") def fetch_some_stuff (some_var ) : return { "the_variable": some_var} my_client = myapiclient () my_client.fetch_some_stuff (3). Ŭ¶óÀ̾ðÆ®´Â Decorated ¸Þ¼µå¿¡¼ Á¦°øÇÏ´Â µ¥ÀÌÅÍ·Î ±âº»ÀûÀ¸·Î HTTP GET ¿äûÀ» ¼öÇàÇÕ´Ï´Ù. API_REQUEST¿¡¼ ¸Þ¼µå = "POST"¸¦ ¼±¾ðÇÏ¿© POST ¿äûÀ» ¼öÇà ÇÒ ¼öµµ ÀÖ½À´Ï´Ù. @ api_request ( "/ API-Endpoint /", method = "POST") DEF FETCH_SOME_STUFF (SOUNT_VAR) : return { "the_variable": some_var} ¹× ¸¶Áö¸·À¸·Î, ´ç½ÅÀÌ ¿øÇÏ´Â °æ¿ì »ç¿ëÀÚ Á¤ÀÇ ÀÀ´ä Ŭ·¡½º¸¦ ¹Ýȯ ÇÒ ¼ö ÀÖ½À´Ï´Ù. API Ŭ¶óÀ̾ðÆ® Ŭ·¡½º¿¡ ´ëÇÑ ÀÀ´ä _ Ŭ·¡½º ¶Ç´Â API_REQUEST DecoratorÀÇ response_class¸¦ Á¦°øÇϽʽÿÀ. »ç¿ëÀÚ Á¤ÀÇ ÀÀ´ä Ŭ·¡½º°¡ API Ŭ¶óÀ̾ðÆ®¿Í API_REQUEST Decorator¿¡¼ ¼±¾ð µÈ °æ¿ì Decoretora°¡ ´õ ±¸Ã¼ÀûÀ̱⠶§¹®¿¡ ÀÌ±æ °ÍÀÔ´Ï´Ù. ÀÀ´ä Ŭ·¡½º´Â ÃʱâÈ¿¡ ´ëÇØ ÇϳªÀÇ Àμö¸¦ ÃëÇؾßÇÕ´Ï´Ù. ¿ø·¡ Response.class MyApicLient (object) : host_name = "http://www.example.com/api response_class = myDefaultResponseclass @api_request ("/ api-endpoint / ") def fetch_some_stuff (some_var) : return { "the_variable": some_var} @api_request ( "/ api-endpoint /", response_class = specializedresponseClass) def fetch_some_stuff (some_var) : return { "the_variable": some_var} Á¦Ç°ÀÇ È¨ÆäÀÌÁö
apyclient. °ü·Ã ¼ÒÇÁÆ®¿þ¾î