README.md(文件已创建)
| @@ -0,0 +1,164 @@ | |||
| 1 | + | # HTTPie Cheatsheet | |
| 2 | + | ||
| 3 | + | Referencia rapida para HTTPie, el cliente HTTP para terminal con sintaxis natural. | |
| 4 | + | ||
| 5 | + | ## Sintaxis basica | |
| 6 | + | ||
| 7 | + | ``` | |
| 8 | + | http [flags] [METHOD] URL [ITEM [ITEM]] | |
| 9 | + | ``` | |
| 10 | + | ||
| 11 | + | ## Operadores | |
| 12 | + | ||
| 13 | + | | Operador | Descripcion | Ejemplo | | |
| 14 | + | |----------|-------------|--------| | |
| 15 | + | | `:` | Header HTTP | `X-API-Token:123` | | |
| 16 | + | | `==` | Query parameter | `q==httpie` | | |
| 17 | + | | `=` | Data field (JSON) | `name=John` | | |
| 18 | + | | `:=` | Raw JSON field | `age:=29` | | |
| 19 | + | | `@` | File upload | `cv@~/resume.pdf` | | |
| 20 | + | | `=@` | Embed file content | `description=@file.txt` | | |
| 21 | + | | `:=@` | Embed JSON file | `data:=@data.json` | | |
| 22 | + | ||
| 23 | + | ## Metodos HTTP | |
| 24 | + | ||
| 25 | + | ```bash | |
| 26 | + | http GET https://api.example.com/users | |
| 27 | + | http POST https://api.example.com/users name=John age:=30 | |
| 28 | + | http PUT https://api.example.com/users/1 name=Jane | |
| 29 | + | http PATCH https://api.example.com/users/1 email=new@example.com | |
| 30 | + | http DELETE https://api.example.com/users/1 | |
| 31 | + | ``` | |
| 32 | + | ||
| 33 | + | ## Nested JSON (v3.0.0+) | |
| 34 | + | ||
| 35 | + | ```bash | |
| 36 | + | http POST https://httpbin.org/post \ | |
| 37 | + | platform[name]=HTTPie \ | |
| 38 | + | platform[apps][]=Terminal \ | |
| 39 | + | platform[apps][]=Desktop \ | |
| 40 | + | address[city]=SanFrancisco \ | |
| 41 | + | address[coordinates][lat]:=37.7749 \ | |
| 42 | + | address[coordinates][lng]:=-122.4194 | |
| 43 | + | ``` | |
| 44 | + | ||
| 45 | + | ## Autenticacion | |
| 46 | + | ||
| 47 | + | ```bash | |
| 48 | + | # Basic auth | |
| 49 | + | http -a usuario:password https://api.example.com/protected | |
| 50 | + | ||
| 51 | + | # Bearer token (v3.0.0+) | |
| 52 | + | http -A bearer -a mi-token https://api.example.com/protected | |
| 53 | + | ||
| 54 | + | # Token en header | |
| 55 | + | http https://api.example.com/protected Authorization:"Bearer mi-token" | |
| 56 | + | ``` | |
| 57 | + | ||
| 58 | + | ## Headers | |
| 59 | + | ||
| 60 | + | ```bash | |
| 61 | + | http GET https://api.example.com X-API-Key:12345 Accept:application/json | |
| 62 | + | ``` | |
| 63 | + | ||
| 64 | + | ## Query parameters | |
| 65 | + | ||
| 66 | + | ```bash | |
| 67 | + | http GET https://api.example.com/search q==httpie page==1 limit==50 | |
| 68 | + | ``` | |
| 69 | + | ||
| 70 | + | ## Subida de archivos | |
| 71 | + | ||
| 72 | + | ```bash | |
| 73 | + | # Subir archivo | |
| 74 | + | http POST https://api.example.com/upload cv@~/documentos/cv.pdf | |
| 75 | + | ||
| 76 | + | # Formulario multipart | |
| 77 | + | http -f POST https://api.example.com/upload cv@~/cv.pdf name=John | |
| 78 | + | ``` | |
| 79 | + | ||
| 80 | + | ## Descarga de archivos | |
| 81 | + | ||
| 82 | + | ```bash | |
| 83 | + | http --download https://example.com/archivo.zip | |
| 84 | + | http --download --output custom-name.zip https://example.com/archivo.zip | |
| 85 | + | ``` | |
| 86 | + | ||
| 87 | + | ## Sesiones | |
| 88 | + | ||
| 89 | + | ```bash | |
| 90 | + | # Crear/guardar sesion | |
| 91 | + | http --session=mi-api https://api.example.com/login user=admin password=1234 | |
| 92 | + | ||
| 93 | + | # Reutilizar sesion | |
| 94 | + | http --session=mi-api https://api.example.com/protected | |
| 95 | + | ||
| 96 | + | # Sesion solo para headers | |
| 97 | + | http --session-read-only=mi-api https://api.example.com/data | |
| 98 | + | ``` | |
| 99 | + | ||
| 100 | + | ## Plugins (v3.0.0+) | |
| 101 | + | ||
| 102 | + | ```bash | |
| 103 | + | httpie cli plugins install httpie-edgegrid | |
| 104 | + | httpie cli plugins install httpie-jwt-auth | |
| 105 | + | httpie cli plugins list | |
| 106 | + | httpie cli plugins uninstall httpie-edgegrid | |
| 107 | + | ``` | |
| 108 | + | ||
| 109 | + | ## Flags utiles | |
| 110 | + | ||
| 111 | + | ```bash | |
| 112 | + | # Verbose | |
| 113 | + | http -v https://api.example.com | |
| 114 | + | # Solo headers | |
| 115 | + | http -h https://api.example.com | |
| 116 | + | # Solo body | |
| 117 | + | http -b https://api.example.com | |
| 118 | + | # Sin color | |
| 119 | + | http --style=none https://api.example.com | |
| 120 | + | # JSON indentado | |
| 121 | + | http --pretty=format https://api.example.com | |
| 122 | + | # Seguir redirecciones | |
| 123 | + | http --follow https://example.com | |
| 124 | + | # Offline | |
| 125 | + | http --offline POST https://api.example.com name=test | |
| 126 | + | # Quiet | |
| 127 | + | http -q POST https://api.example.com data=value | |
| 128 | + | # Chunked | |
| 129 | + | http --chunked POST https://api.example.com data=value | |
| 130 | + | # Raw body | |
| 131 | + | http --raw '{"key":"value"}' POST https://api.example.com | |
| 132 | + | # Timeout | |
| 133 | + | http --timeout 30 https://api.example.com | |
| 134 | + | # Response metadata | |
| 135 | + | http -vv https://api.example.com | |
| 136 | + | ``` | |
| 137 | + | ||
| 138 | + | ## Output personalizado | |
| 139 | + | ||
| 140 | + | ```bash | |
| 141 | + | http -p HBody https://api.example.com | |
| 142 | + | # H = headers response, B = body response, h = headers request, b = body request | |
| 143 | + | ``` | |
| 144 | + | ||
| 145 | + | ## Verificacion SSL | |
| 146 | + | ||
| 147 | + | ```bash | |
| 148 | + | http --verify=no https://ejemplo.com | |
| 149 | + | http --verify=/ruta/ca-bundle.crt https://ejemplo.com | |
| 150 | + | ``` | |
| 151 | + | ||
| 152 | + | ## Proxies | |
| 153 | + | ||
| 154 | + | ```bash | |
| 155 | + | http --proxy=http:http://proxy.local:8080 https://api.example.com | |
| 156 | + | http --proxy=https:http://proxy.local:8080 https://api.example.com | |
| 157 | + | ``` | |
| 158 | + | ||
| 159 | + | ## Mas informacion | |
| 160 | + | ||
| 161 | + | - [Documentacion oficial](https://httpie.io/docs/cli) | |
| 162 | + | - [Repositorio GitHub](https://github.com/httpie/cli) | |
| 163 | + | - [HTTPie for Desktop](https://httpie.io/desktop) | |
| 164 | + | - [Pie Host](https://pie.dev) | |
上一页
下一页