Postman 动态变量

2023-04-04 10:33 更新

Postman 使用faker 库生成样本数据,包括随机名称、地址、电子邮件地址等等。您可以多次使用这些预定义变量来为每个请求返回不同的值。

您可以像 Postman 中的任何其他变量一样使用这些变量。它们的值是在执行时生成的,它们的名称以$符号开头,例如$guidor $timestamp。

以下是动态变量的列表,其值是在请求/收集运行期间随机生成的。

要在预请求或测试脚本中使用动态变量,您需要使用pm.variables.replaceIn(),例如pm.variables.replaceIn('{{$randomFirstName}}').

常见的

变量名描述例子
$guiduuid-v4风格指南"611c2e81-2ccb-42d8-9ddc-2d0bfa65c1b4"
"3a721b7f-7dc9-4c45-9777-516942b98e0d"
"22eca807-006b-47df-9511-e92e37f5071a"
$timestamp当前 UNIX 时间戳,以秒为单位15627571071562757108,1562757109
$isoTimestamp零 UTC 时的当前 ISO 时间戳2020-06-09T21:10:36.177Z
2019-10-21T06:05:50.000Z
2019-07-29T18:29:00.000Z
$randomUUID一个随机的 36 个字符的 UUID"6929bb52-3ab2-448a-9796-d6480ecad36b"
"53151b27-034f-45a0-9f0a-d7b6075b67d0"
"727131a2-2717-44ad-ab02-006587e947dc"

文本、数字和颜色

变量名描述例子
$randomAlphaNumeric一个随机的字母数字字符6"y","z"
$randomBoolean随机布尔值true,false
$randomInt0 到 1000 之间的随机整数802494,200
$randomColor随机颜色"red""fuchsia","grey"
$randomHexColor一个随机的十六进制值"#47594a""#431e48","#106f21"
$randomAbbreviation随机缩写SQLPCI,JSON

互联网和 IP 地址

变量名描述例子
$randomIP一个随机的 IPv4 地址241.102.234.100,216.7.27.38
$randomIPV6一个随机的 IPv6 地址dbe2:7ae6:119b:c161:1560:6dda:3a9b:90a9
c482:23a4:ce4c:a668:7736:6cc5:b0b6:cc37
c791:18d1:fbba:87d8:d929:22aa:5a0a:ac3d
$randomMACAddress随机MAC地址33:d4:68:5f:b4:c7,1f:6e:db:3d:ed:fa
$randomPassword一个随机的 15 个字符的字母数字密码t9iXe7COoDKv8k3,QAzNFQtvR9cg2rq
$randomLocale随机的两字母语言代码 (ISO 639-1)"ny""sr","si"
$randomUserAgent随机用户代理Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.9.8; rv:15.6) Gecko/20100101 Firefox/15.6.6
Opera/10.27 (Windows NT 5.3; U; AB Presto/2.9.177 Version/10.00)
Mozilla/5.0 (Windows NT 6.2; rv:13.5) Gecko/20100101 Firefox/13.5.6
$randomProtocol一个随机的互联网协议"http","https"
$randomSemver一个随机的语义版本号7.0.52.5.8,6.4.9

名称

变量名描述例子
$randomFirstName一个随机的名字EthanChandler,Megane
$randomLastName一个随机的姓氏SchadenSchneider,Willms
$randomFullName一个随机的名字和姓氏Connie RunolfsdottirSylvan Fay,Jonathon Kunze
$randomNamePrefix随机名称前缀Dr.Ms.,Mr.
$randomNameSuffix随机名称后缀IMD,DDS

职业

变量名描述例子
$randomJobArea随机工作区MobilityIntranet,Configuration
$randomJobDescriptor一个随机的工作描述符ForwardCorporate,Senior
$randomJobTitle一个随机的职位International Creative Liaison,
Product Factors Officer,
Future Interactions Executive
$randomJobType随机工作类型SupervisorManager,Coordinator

电话、地址和位置

变量名描述例子
$randomPhoneNumber一个随机的十位数电话号码700-008-5275494-261-3424,662-302-7817
$randomPhoneNumberExt一个带分机号的随机电话号码(12 位数字)27-199-983-3864,99-841-448-2775
$randomCity一个随机的城市名称SpinkahavenKorbinburgh,Lefflerport
$randomStreetName一个随机的街道名称Kuhic IslandGeneral Street,Kendrick Springs
$randomStreetAddress一个随机的街道地址5742 Harvey Streets,47906 Wilmer Orchard
$randomCountry一个随机的国家Lao People's Democratic RepublicKazakhstan,Austria
$randomCountryCode一个随机的两个字母的国家代码(ISO 3166-1 alpha-2)CVMD,TD
$randomLatitude随机纬度坐标55.209927.3644,-84.7514
$randomLongitude随机经度坐标40.6609171.7139,-159.9757

图片

变量名描述例子
$randomAvatarImage随机头像图片https://s3.amazonaws.com/uifaces/faces/twitter/johnsmithagency/128.jpg
https://s3.amazonaws.com/uifaces/faces/twitter/xadhix/128.jpg
https://s3.amazonaws.com/uifaces/faces/twitter/martip07/128.jpg
$randomImageUrl随机图像的 URLhttp://lorempixel.com/640/480
$randomAbstractImage随机抽象图像的 URLhttp://lorempixel.com/640/480/abstract
$randomAnimalsImage随机动物图像的 URLhttp://lorempixel.com/640/480/animals
$randomBusinessImage随机库存商业图片的 URLhttp://lorempixel.com/640/480/business
$randomCatsImage随机猫图像的 URLhttp://lorempixel.com/640/480/cats
$randomCityImage随机城市图像的 URLhttp://lorempixel.com/640/480/city
$randomFoodImage随机食物图片的 URLhttp://lorempixel.com/640/480/food
$randomNightlifeImage随机夜生活图像的 URLhttp://lorempixel.com/640/480/nightlife
$randomFashionImage随机时尚图片的 URLhttp://lorempixel.com/640/480/fashion
$randomPeopleImage人的随机图像的 URLhttp://lorempixel.com/640/480/people
$randomNatureImage随机自然图像的 URLhttp://lorempixel.com/640/480/nature
$randomSportsImage随机运动图像的 URLhttp://lorempixel.com/640/480/sports
$randomTransportImage随机交通图像的 URLhttp://lorempixel.com/640/480/transport
$randomImageDataUri随机图像数据 URIdata:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20baseProfile%3D%22full%22%20width%3D%22undefined%22%20height%3D%22undefined%22%3E%20%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22grey%22%2F%3E%20%20%3Ctext%20x%3D%220%22%20y%3D%2220%22%20font-size%3D%2220%22%20text-anchor%3D%22start%22%20fill%3D%22white%22%3Eundefinedxundefined%3C%2Ftext%3E%20%3C%2Fsvg%3E

金融

变量名描述例子
$randomBankAccount一个随机的 8 位银行帐号0945407365653440,75728757
$randomBankAccountName一个随机的银行账户名Home Loan Account,, Checking AccountSavings Account_Auto Loan Account
$randomCreditCardMask一个随机的掩码信用卡号36225815,6257
$randomBankAccountBic随机 BIC(银行识别码)EZIAUGJ1KXCUTVJ1,DIVIPLL1
$randomBankAccountIban一个随机的 15-31 个字符的 IBAN(国际银行帐号)MU20ZPUN3039684000618086155TKZ
BR7580569810060080800805730W2
XK241602002200395017
$randomTransactionType随机交易类型invoicepayment,deposit
$randomCurrencyCode一个随机的 3 字母货币代码 (ISO-4217)CDFZMK,GNF
$randomCurrencyName一个随机的货币名称CFP FrancCordoba Oro,Pound Sterling
$randomCurrencySymbol随机货币符号$,£
$randomBitcoin一个随机的比特币地址3VB8JGT7Y4Z63U68KGGKDXMLLH5
1GY5TL5NEX3D1EA0TCWPLGVPQF5EAF
14IIEXV2AKZAHSCY2KNYP213VRLD

商业

变量名描述例子
$randomCompanyName一个随机的公司名称Johns - Kassulke,Grady LLC
$randomCompanySuffix一个随机的公司后缀IncLLC,Group
$randomBs商务演讲的随机短语killer leverage schemas,
bricks-and-clicks deploy markets,
world-class unleash platforms
$randomBsAdjective一个随机的商务用语形容词viral24/7,24/365
$randomBsBuzz一个随机的商业流行语repurposeharness,transition
$randomBsNoun一个随机的商务名词e-servicesmarkets,interfaces

口头禅

变量名描述例子
$randomCatchPhrase随意的口头禅Future-proofed heuristic open architecture,
Quality-focused executive toolset,
Grass-roots real-time definition
$randomCatchPhraseAdjective一个随机的流行语形容词Self-enablingBusiness-focused,Down-sized
$randomCatchPhraseDescriptor一个随机的标语描述符bandwidth-monitoredneeds-based,homogeneous
$randomCatchPhraseNoun随机生成一个标语名词secured linesuperstructure,installation

数据库

变量名描述例子
$randomDatabaseColumn一个随机的数据库列名updatedAttoken,group
$randomDatabaseType随机数据库类型tinyint,text
$randomDatabaseCollation随机数据库整理cp1250_binutf8_general_ci,cp1250_general_ci
$randomDatabaseEngine随机数据库引擎MyISAMInnoDB,Memory

日期

变量名描述例子
$randomDateFuture一个随机的未来日期时间Tue Mar 17 2020 13:11:50 GMT+0530 (India Standard Time),
Fri Sep 20 2019 23:51:18 GMT+0530 (India Standard Time),
Thu Nov 07 2019 19:20:06 GMT+0530 (India Standard Time)
$randomDatePast一个随机的过去日期时间Sat Mar 02 2019 09:09:26 GMT+0530 (India Standard Time),
Sat Feb 02 2019 00:12:17 GMT+0530 (India Standard Time),
Thu Jun 13 2019 03:08:43 GMT+0530 (India Standard Time)
$randomDateRecent一个随机的最近日期时间Tue Jul 09 2019 23:12:37 GMT+0530 (India Standard Time),
Wed Jul 10 2019 15:27:11 GMT+0530 (India Standard Time),
Wed Jul 10 2019 01:28:31 GMT+0530 (India Standard Time)
$randomWeekday一个随机的工作日ThursdayFriday,Monday
$randomMonth一个随机的月份FebruaryMay,January

域、电子邮件和用户名

变量名描述例子
$randomDomainName随机域名gracie.bizarmando.biz,trevor.info
$randomDomainSuffix随机域后缀orgnet,com
$randomDomainWord一个随机的不合格域名gwenjaden,donnell
$randomEmail一个随机的电子邮件地址Pablo62@gmail.comRuthe42@hotmail.com,Iva.Kovacek61@hotmail.com
$randomExampleEmail来自“示例”域的随机电子邮件地址Talon28@example.comQuinten_Kerluke45@example.net,Casey81@example.net
$randomUserName随机用户名Jarrell.GutkowskiLottie.Smitham24,Alia99
$randomUrl随机网址https://anais.nethttps://tristin.net,http://jakob.name

文件和目录

变量名描述例子
$randomFileName随机文件名(包括不常见的扩展名)neural_sri_lanka_rupee_gloves.gdoc,
plastic_awesome_garden.tif,
incredible_ivory_agent.lzh
$randomFileType随机文件类型(包括不常见的文件类型)modelapplication,video
$randomFileExt随机文件扩展名(包括不常见的扩展名)warbook,fsc
$randomCommonFileName随机文件名well_modulated.mpg4,
rustic_plastic_tuna.gif,
checking_account_end_to_end_robust.wav
$randomCommonFileType一种随机的、常见的文件类型application,audio
$randomCommonFileExt一个随机的、通用的文件扩展名m2vwav,png
$randomFilePath随机文件路径/home/programming_chicken.cpio,
/usr/obj/fresh_bandwidth_monitored_beauty.onetoc,
/dev/css_rustic.pm
$randomDirectoryPath随机目录路径/usr/bin/root,/usr/local/bin
$randomMimeType一个随机的 MIME 类型audio/vnd.vmx.cvsd,
application/vnd.groove-identity-message,
application/vnd.oasis.opendocument.graphics-template

专卖店

变量名描述例子
$randomPrice0.00 到 1000.00 之间的随机价格531.55488.76,511.56
$randomProduct随机产品TowelsPizza,Pants
$randomProductAdjective一个随机的产品形容词UnbrandedIncredible,Tasty
$randomProductMaterial随机产品材料SteelPlastic,Frozen
$randomProductName一个随机的产品名称Handmade Concrete Tuna,Refined Rubber Hat
$randomDepartment一个随机的商业类别ToolsMovies,Electronics

语法

变量名描述例子
$randomNoun随机名词matrixbus,bandwidth
$randomVerb随机动词parsequantify,navigate
$randomIngverb以结尾的随机动词-ingsynthesizingnavigating,backing up
$randomAdjective一个随机的形容词auxiliarymulti-byte,back-end
$randomWord一个随机的词withdrawalinfrastructures,IB
$randomWords一些随意的话Samoa Synergistic sticky copying Grocery,
Corporate Springs,
Christmas Island Ghana Quality
$randomPhrase随机短语You can't program the monitor without navigating the mobile XML program!,
overriding the capacitor won't do anything, we need to compress the optical SMS transmitter!,
I'll generate the virtual AI program, that should microchip the RAM monitor!

求数

变量名描述例子
$randomLoremWordlorem ipsum 文本的随机词est
$randomLoremWordslorem ipsum文本的一些随机词vel repellat nobis
$randomLoremSentencelorem ipsum文本的随机句子Molestias consequuntur nisi non quod.
$randomLoremSentences随机的 2 到 6 个 lorem ipsum 文本句子Et sint voluptas similique iure amet perspiciatis vero sequi atque. Ut porro sit et hic. Neque aspernatur vitae fugiat ut dolore et veritatis. Ab iusto ex delectus animi. Voluptates nisi iusto. Impedit quod quae voluptate qui.
$randomLoremParagraph一段随机的 lorem ipsum 文本Ab aliquid odio iste quo voluptas voluptatem dignissimos velit. Recusandae facilis qui commodi ea magnam enim nostrum quia quis. Nihil est suscipit assumenda ut voluptatem sed. Esse ab voluptas odit qui molestiae. Rem est nesciunt est quis ipsam expedita consequuntur.
$randomLoremParagraphs3 个随机段落的 lorem ipsum 文本Voluptatem rem magnam aliquam ab id aut quaerat. Placeat provident possimus voluptatibus dicta velit non aut quasi. Mollitia et aliquam expedita sunt dolores nam consequuntur. Nam dolorum delectus ipsam repudiandae et ipsam ut voluptatum totam. Nobis labore labore recusandae ipsam quo.


Voluptatem occaecati omnis debitis eum libero. Veniam et cum unde. Nisi facere repudiandae error aperiam expedita optio quae consequatur qui. Vel ut sit aliquid omnis. Est placeat ducimus. Libero voluptatem eius occaecati ad sint voluptatibus laborum provident iure.

Autem est sequi ut tenetur omnis enim. Fuga nisi dolor expedita. Ea dolore ut et a nostrum quae ut reprehenderit iste. Numquam optio magnam omnis architecto non. Est cumque laboriosam quibusdam eos voluptatibus velit omnis. Voluptatem officiis nulla omnis ratione excepturi.

$randomLoremText随机数量的 lorem ipsum 文本Quisquam asperiores exercitationem ut ipsum. Aut eius nesciunt. Et reiciendis aut alias eaque. Nihil amet laboriosam pariatur eligendi. Sunt ullam ut sint natus ducimus. Voluptas harum aspernatur soluta rem nam.
$randomLoremSlug随机 lorem ipsum URL slugeos-aperiam-accusamusbeatae-id-molestiae,qui-est-repellat
$randomLoremLines1 到 5 行随机 lorem ipsumDucimus in ut mollitia.
A itaque non.
Harum temporibus nihil voluptas.
Iste in sed et nesciunt in quaerat sed.


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号